Re: Problem of function calls from map()

2006-08-28 Thread Dasn
On Tue, Aug 22, 2006 at 04:50:39PM +0200, Fredrik Lundh wrote: > (you cannot really use "profile" to *benchmark* things written in > Python either; the profiler tells you where a given program spends the > time, not how fast it is in com- parision with other programs) Thanks for your indication.

Re: Problem of function calls from map()

2006-08-27 Thread Steve Holden
Fredrik Lundh wrote: > Steve Holden wrote: > > >>Well I guess if people wanted to argue for keeping the functionals this >>should be on the list ... > > > who's arguing ? > Please note that word "if", but you are surely aware that there havebeen suggestions that Python's functional programmin

Re: Problem of function calls from map()

2006-08-24 Thread Fredrik Lundh
Steve Holden wrote: > Well I guess if people wanted to argue for keeping the functionals this > should be on the list ... who's arguing ? is this perhaps a little like the "now that we have lexical scoping, the default argument object binding trick is no longer needed" myth ? -- http://ma

Re: Problem of function calls from map()

2006-08-23 Thread Steve Holden
Fredrik Lundh wrote: > Sion Arrowsmith wrote: > > >>>(you cannot really use "profile" to *benchmark* things written in Python >>>either; the >>>profiler tells you where a given program spends the time, not how fast it is >>>in com- >>>parision with other programs) >> >>Hmm. Playing around with

Re: Problem of function calls from map()

2006-08-22 Thread Fredrik Lundh
Sion Arrowsmith wrote: >> (you cannot really use "profile" to *benchmark* things written in Python >> either; the >> profiler tells you where a given program spends the time, not how fast it is >> in com- >> parision with other programs) > > Hmm. Playing around with timeit suggests that althoug

Re: Problem of function calls from map()

2006-08-22 Thread Sion Arrowsmith
Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Sion Arrowsmith wrote: >> I think there's something weird going on -- sp4 should be making >> 154563 calls to str.split. So no wonder it goes faster -- it's not doing >> any work. >the problem is that he's using a Python-level profiler to benchmark things

Re: Problem of function calls from map()

2006-08-22 Thread Fredrik Lundh
Sion Arrowsmith wrote: > I think there's something weird going on -- sp4 should be making > 154563 calls to str.split. So no wonder it goes faster -- it's not doing > any work. of course it does: >>> lines = ["line\tone", "line\ttwo"] >>> [s.split("\t") for s in lines] [['line', 'one'], ['line',

Re: Problem of function calls from map()

2006-08-22 Thread Paul McGuire
"Georg Brandl" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paul McGuire wrote: > > "Dasn" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> > >> Hi, there. > >> > >> 'lines' is a large list of strings each of which is seperated by '\t' > >> >>> lines = ['bla\tbl

Re: Problem of function calls from map()

2006-08-22 Thread Sion Arrowsmith
Dasn <[EMAIL PROTECTED]> wrote: ># size of 'dict.txt' is about 3.6M, 154563 lines >f = open('dict.txt', 'r') >print "Reading lines..." >lines = f.readlines() >print "Done." [ ... ] >def sp1(lines): > """> sp1() -- List-comprehension""" > return [s.split('\t') for s in lines] [ ..

Re: Problem of function calls from map()

2006-08-22 Thread Georg Brandl
Paul McGuire wrote: > "Dasn" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> Hi, there. >> >> 'lines' is a large list of strings each of which is seperated by '\t' >> >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ] >> >> I wanna split each string into a list. For speed, using m

Re: Problem of function calls from map()

2006-08-22 Thread Peter Otten
Dasn wrote: > # size of 'dict.txt' is about 3.6M, 154563 lines > f = open('dict.txt', 'r') > lines = f.readlines() > def sp0(lines): > """> sp0() -- Normal 'for' loop""" > l = [] > for line in lines: > l.append(line.split('\t')) > return l Wh

Re: Problem of function calls from map()

2006-08-21 Thread Dasn
Thanks for your reply. Well, please drop a glance at my current profile report: # test.py - import os, sys, profile print os.uname() print sys.version # size of 'dict.txt' is about 3.6M, 154563 lines f = open('dict.txt', 'r') print "Reading lines..."

Re: Problem of function calls from map()

2006-08-21 Thread Paul McGuire
>>tmp is the function that split will call once per list item should be tmp is the function that *map* will call once per list item -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem of function calls from map()

2006-08-21 Thread Paul McGuire
"Dasn" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi, there. > > 'lines' is a large list of strings each of which is seperated by '\t' > >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ] > > I wanna split each string into a list. For speed, using map() instead > of 'for' loop.

Re: Problem of function calls from map()

2006-08-21 Thread Diez B. Roggisch
Dasn wrote: > > Hi, there. > > 'lines' is a large list of strings each of which is seperated by '\t' lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ] > > I wanna split each string into a list. For speed, using map() instead > of 'for' loop. 'map(str.split, lines)' works fine , but... > when I

Re: Problem of function calls from map()

2006-08-21 Thread Tim Lesher
Dasn wrote: > So how to put '\t' argument to split() in map() ? How much is the lambda costing you, according to your profiler? Anyway, what you really want is a list comprehension: l = [line.split('\t') for line in lines] -- http://mail.python.org/mailman/listinfo/python-list

Problem of function calls from map()

2006-08-21 Thread Dasn
Hi, there. 'lines' is a large list of strings each of which is seperated by '\t' >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ] I wanna split each string into a list. For speed, using map() instead of 'for' loop. 'map(str.split, lines)' works fine , but... when I was trying: >>> l = map(str.