Re: performance of tight loop

2010-12-14 Thread Peter Otten
Peter Otten wrote: > gry wrote: > >> [python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] >> I have a little data generator that I'd like to go faster... any >> suggestions? >> maxint is usually 9223372036854775808(max 64bit int), but could >> occasionally be 99. >> width is usual

Re: performance of tight loop

2010-12-14 Thread Peter Otten
gry wrote: > [python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] > I have a little data generator that I'd like to go faster... any > suggestions? > maxint is usually 9223372036854775808(max 64bit int), but could > occasionally be 99. > width is usually 500 or 1600, rows ~ 5000. >

Re: performance of tight loop

2010-12-14 Thread Paul Rubin
gry writes: ... > rest = ['%d' % randint(1, mx) for i in range(wd - 1)] > for i in range(i,i+rows): ... One thing that immediately comes to mind is use xrange instead of range. Also, instead of first = ['%d' % i] rest = ['%d' % randint(1, mx) for i in range(wd - 1)] re

Re: performance of tight loop

2010-12-14 Thread Ulrich Eckhardt
Thank you for the explanation, Ryan! Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list

Re: performance of tight loop

2010-12-13 Thread Ryan Kelly
On Tue, 2010-12-14 at 08:08 +0100, Ulrich Eckhardt wrote: > Steven D'Aprano wrote: > > Replacing "while True" with "while 1" may save a tiny bit of overhead. > > Whether it is significant or not is another thing. > > Is this the price for an intentional complexity or just a well-known > optimizer

Re: performance of tight loop

2010-12-13 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > Replacing "while True" with "while 1" may save a tiny bit of overhead. > Whether it is significant or not is another thing. Is this the price for an intentional complexity or just a well-known optimizer deficiency? Just curious... Uli -- Domino Laser GmbH Geschäftsführ

Re: performance of tight loop

2010-12-13 Thread Ulrich Eckhardt
gry wrote: > I have a little data generator that I'd like to go faster... any > suggestions? > maxint is usually 9223372036854775808(max 64bit int), but could > occasionally be 99. > width is usually 500 or 1600, rows ~ 5000. > > from random import randint > > def row(i, wd, mx): > first = ['

Re: performance of tight loop

2010-12-13 Thread Steven D'Aprano
On Mon, 13 Dec 2010 18:50:38 -0800, gry wrote: > [python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] I > have a little data generator that I'd like to go faster... any > suggestions? > maxint is usually 9223372036854775808(max 64bit int), but could > occasionally be 99. > width is

performance of tight loop

2010-12-13 Thread gry
[python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] I have a little data generator that I'd like to go faster... any suggestions? maxint is usually 9223372036854775808(max 64bit int), but could occasionally be 99. width is usually 500 or 1600, rows ~ 5000. from random import randi