[Numpy-discussion] Relative speed

Ralf Gommers ralf.gommers@gmail....
Thu Aug 29 13:00:49 CDT 2013


On Thu, Aug 29, 2013 at 3:41 PM, Jonathan T. Niehof <jniehof@lanl.gov>wrote:

> On 08/29/2013 09:33 AM, Anubhab Baksi wrote:
> > Hi,
> > I need to know about the relative speed (i.e., which one is faster) of
> > the followings:
> > 1. list and numpy array, tuples and numpy array
> > 2. list of tuples and numpy matrix (first one is rectangular)
> > 3. random.randint() and numpy.random.random_integers()
>

Hi Anubhab, if you have a reasonably large amount of data (say O(100)),
always try to use numpy arrays and not lists or tuples - it'll be faster.
I'd recommend not to use numpy.matrix, it's speed will be similar to numpy
arrays but it has some peculiarities that you'd rather not deal with. For
the random numbers I'm not sure without checking, just timing it in ipython
with %timeit is indeed the way to go.

Cheers,
Ralf


> African or European?
>

Why on earth would you ask that?



> It really depends on what you're doing with it. The ipython %timeit
> magic is pretty useful for answering that question. Note that the answer
> may change dramatically based on the size of the data set.
>
> --
> Jonathan Niehof
> ISR-3 Space Data Systems
> Los Alamos National Laboratory
> MS-D466
> Los Alamos, NM 87545
>
> Phone: 505-667-9595
> email: jniehof@lanl.gov
>
> Correspondence /
> Technical data or Software Publicly Available
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130829/eca7e68f/attachment.html 


More information about the NumPy-Discussion mailing list