Re: python vs perl performance test

2007-12-14 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: > ... When I first translated it to Python verbatim, > the Python script took almost 30 secs to run. > So far, the best I can do is 11.2 secs using this: > > from random import randrange > from itertools import imap, repeat > from operator import getitem, add, getslice >

Re: python vs perl performance test

2007-12-13 Thread igor . tatarinov
On Dec 13, 1:23 pm, Jakub Stolarski <[EMAIL PROTECTED]> wrote: > If all you need is the result here's simpler and more efficient code: > > from random import randrange > sum = 100 * randrange(128) > print "Sum is ", sum > > And the same in perl: > > my $sum = 100 * int(rand(128)); > print "Sum is $

Re: python vs perl performance test

2007-12-13 Thread Jakub Stolarski
On 13 Gru, 19:11, [EMAIL PROTECTED] wrote: > There's got to be a simpler and more efficient way to do this. > Can you help? > > Thanks, > igor If all you need is the result here's simpler and more efficient code: from random import randrange sum = 100 * randrange(128) print "Sum is ", sum And t

Re: python vs perl performance test

2007-12-13 Thread Arnaud Delobelle
On Dec 13, 6:11 pm, [EMAIL PROTECTED] wrote: > from random import randrange > from itertools import imap, repeat > from operator import getitem, add, getslice > > result = 0 > zeros = [0]*100 > for i in xrange (10): > s = [chr(randrange(128))] * 1024 > starts = repeat(randrange(900), 1

Re: python vs perl performance test

2007-12-13 Thread Chris Mellon
On Dec 13, 2007 12:11 PM, <[EMAIL PROTECTED]> wrote: > First, let me admit that the test is pretty dumb (someone else > suggested it :) but since I am new to Python, I am using it to learn > how to write efficient code. > > my $sum = 0; > foreach (1..10) { > my $str = chr(rand(128)) x 1024