On 19 Des, 02:28, Ryan Kelly wrote:
> Not so. If you use the "dis" module to peek at the bytecode generated
> for a list comprehension, you'll see it's very similar to that generated
> for an explicit for-loop. The byte-code for a call to map is very
> different.
First, you failed to realize t
On Sat, 19 Dec 2009 12:28:32 +1100, Ryan Kelly wrote:
>> Anything else being equal, list comprehensions will be the faster
>> becuase they incur fewer name and attribute lookups. It will be the
>> same as the difference between a for loop and a call to map. A list
>> comprehension is basically an
Ryan Kelly wrote:
Someone else wrote:
It will be the
same as the difference between a for loop and a call to map.
Not so. If you use the "dis" module to peek at the bytecode generated
for a list comprehension, you'll see it's very similar to that generated
for an explicit for-loop.
The usua
> > Tenting the time spent by each approach (using time.clock()), with a
> > file with about 100,000 entries, I get 0.03s for the loop and 0.05s
> > for the listcomp.
>
> Anything else being equal, list comprehensions will be the faster
> becuase they incur fewer name and attribute lookups. It wil
On Fri, Dec 18, 2009 at 11:55 AM, sturlamolden wrote:
> On 17 Des, 18:37, Carlos Grohmann wrote:
>
> > Tenting the time spent by each approach (using time.clock()), with a
> > file with about 100,000 entries, I get 0.03s for the loop and 0.05s
> > for the listcomp.
> >
> > thoughts?
>
> Let me as
On 17 Des, 18:37, Carlos Grohmann wrote:
> Tenting the time spent by each approach (using time.clock()), with a
> file with about 100,000 entries, I get 0.03s for the loop and 0.05s
> for the listcomp.
>
> thoughts?
Let me ask a retoric question:
- How much do you really value 20 ms of CPU time
On Dec 17, 9:37 am, Carlos Grohmann wrote:
> Tenting the time spent by each approach (using time.clock()), with a
> file with about 100,000 entries, I get 0.03s for the loop and 0.05s
> for the listcomp.
>
> thoughts?
You shouldn't trust your intuition in things like this. Some features
were add
On 17 Des, 18:42, "Alf P. Steinbach" wrote:
> Have you tried this with
>
> dip1 = [dp - 0.01 if dp == 90 else dp for dp in dipList]
And for comparison with map:
map(lambda dp: dp - 0.01 if dp == 90 else dp, dipList)
--
http://mail.python.org/mailman/listinfo/python-list
On 17 Des, 18:37, Carlos Grohmann wrote:
> Tenting the time spent by each approach (using time.clock()), with a
> file with about 100,000 entries, I get 0.03s for the loop and 0.05s
> for the listcomp.
>
> thoughts?
Anything else being equal, list comprehensions will be the faster
becuase they i
> Have you tried this with
>
> dip1 = [dp - 0.01 if dp == 90 else dp for dp in dipList]
>
Yes that is better! many thanks!
--
http://mail.python.org/mailman/listinfo/python-list
* Carlos Grohmann:
Hello all
I am testing my code with list comprehensions against for loops.
the loop:
dipList=[float(val[1]) for val in datalist]
dip1=[]
for dp in dipList:
if dp == 90:
dip1.append(dp - 0.01)
else:
dip1.append(dp)
listcomp
Hello all
I am testing my code with list comprehensions against for loops.
the loop:
dipList=[float(val[1]) for val in datalist]
dip1=[]
for dp in dipList:
if dp == 90:
dip1.append(dp - 0.01)
else:
dip1.append(dp)
listcomp:
dipList=[float
12 matches
Mail list logo