# Converting python code into julia code

**URL:** https://discourse.julialang.org/t/converting-python-code-into-julia-code/98991
**Category:** General Usage
**Tags:** python, convert, signal-processing
**Created:** [May 17, 2023, 10:55am UTC](https://discourse.julialang.org/t/converting-python-code-into-julia-code/98991 "2023-05-17T10:55:38Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 17, 2023, 1:05pm UTC](https://discourse.julialang.org/t/converting-python-code-into-julia-code/98991/8 "2023-05-17T13:05:51Z")

</div>

> [@GunnarFarneback](#):
>
> In this case it’s all a matter of filling an array with entries from a vector, so just do a double loop.

The OP seems to be trying to re-implement the Matlab `buffer` function (see their other thread: [Convert buffer function existing in matlab to julia language](https://discourse.julialang.org/t/convert-buffer-function-existing-in-matlab-to-julia-language/98926)). (Apparently they found a Python implementation and are now trying to port that, rather than starting from the spec?) This really seems better to implement via an array or iterator of [views](https://docs.julialang.org/en/v1/base/arrays/#Views-(SubArrays-and-other-view-types)) rather than copies.

See my [suggestion in the other thread](https://discourse.julialang.org/t/convert-buffer-function-existing-in-matlab-to-julia-language/98926/6), which boils down to the one-liner `@views stack([X[i:i+n-1] for i in firstindex(X):n-p:lastindex(X)-n+1])`.

---

_[View the full topic](https://discourse.julialang.org/t/converting-python-code-into-julia-code/98991)._
