On 23/02/07, Alexander Michael <[EMAIL PROTECTED]> wrote:

> I still find the ring buffer solution appealing, but I did not see a
> way to stack two arrays together without creating copies. Am I missing
> a bit of numpy cleverness?

The short answer is no; the stride in memory from one element to the
next must always be the same in an array, and so it's impossible to
join two arrays like that without copying.

There is a ring-buffer-like idea that lets you do less copying; if you
need slices of length N, you can choose M>=2N and maintain a
ringbuffer of length M instead; when you push something into the
M-N+jth position, you also push (i.e., copy) it into the jth position.
Then you can always take a contiguous slice starting anywhere from 0
to M-N-1, and you need only copy a small fraction (N/M or so) of the
values pushed on. You never move values in the ringbuffer, and there
are no big spikes in CPU time.

Anne
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to