Andrea,
One note: transposing is almost free — it just rearranges the strides —
I.e. changed how the array is interpreted. It doesn’t actually move the
data around.
-CHB
Sent from my iPhone
On Oct 7, 2017, at 2:58 AM, Andrea Gavana wrote:
Apologies, correct timeit code this time (I had gotten
On Sat, 7 Oct 2017 at 16.59, Nicholas Nadeau
wrote:
> Hi Andrea!
>
> Checkout the following SO answers for similar contexts:
> -
> https://stackoverflow.com/questions/22108488/are-list-comprehensions-and-functional-functions-faster-than-for-loops
> -
> https://stackoverflow.com/questions/30245397
Hi Andrea!
Checkout the following SO answers for similar contexts:
-
https://stackoverflow.com/questions/22108488/are-list-comprehensions-and-functional-functions-faster-than-for-loops
-
https://stackoverflow.com/questions/30245397/why-is-list-comprehension-so-faster
To better visualize the issue
Apologies, correct timeit code this time (I had gotten the wrong shape for
the output matrix in the loop case):
if __name__ == '__main__':
repeat = 1000
items = [Item('item_%d'%(i+1)) for i in xrange(500)]
output = numpy.asarray([item.do_something() for item in items]).T
statemen
Hi All,
I have this little snippet of code:
import timeit
import numpy
class Item(object):
def __init__(self, name):
self.name = name
self.values = numpy.random.rand(8, 1)
def do_something(self):
sv = self.values.sum(axis=0)
array = numpy.empty((8,