[Numpy-discussion] Relative speed
Thu Aug 29 13:00:49 CDT 2013
On Thu, Aug 29, 2013 at 3:41 PM, Jonathan T. Niehof <email@example.com>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.
> 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
> Los Alamos, NM 87545
> Phone: 505-667-9595
> email: firstname.lastname@example.org
> Correspondence /
> Technical data or Software Publicly Available
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion