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.
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
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
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
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
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
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',
"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
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]
[ ..
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
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
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..."
>>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
"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.
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
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
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.
17 matches
Mail list logo