[Numpy-discussion] faster code

Davide Lasagna lasagnadavide at gmail.com
Sun May 16 16:57:14 EDT 2010


Well, actually np.arange(2**24) was just to test the following line ;). I'm
particularly concerned about memory consumption rather than speed.

On 16 May 2010 22:53, Brent Pedersen <bpederse at gmail.com> wrote:

> On Sun, May 16, 2010 at 12:14 PM, Davide Lasagna
> <lasagnadavide at gmail.com> wrote:
> > Hi all,
> > What is the fastest and lowest memory consumption way to compute this?
> > y = np.arange(2**24)
> > bases = y[1:] + y[:-1]
> > Actually it is already quite fast, but i'm not sure whether it is
> occupying
> > some temporary memory
> > is the summation. Any help is appreciated.
> > Cheers
> > Davide
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
>
> how about something like this? may have off-by-1 somewhere.
>
> >>> bases = np.arange(1, 2*2**24-1, 2)
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100516/6c895967/attachment.html>


More information about the NumPy-Discussion mailing list