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
On 19 Des, 02:28, Ryan Kelly r...@rfk.id.au 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
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
On 17 Des, 18:37, Carlos Grohmann carlos.grohm...@gmail.com 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
On 17 Des, 18:42, Alf P. Steinbach al...@start.no 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 Dec 17, 9:37 am, Carlos Grohmann carlos.grohm...@gmail.com 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.
On 17 Des, 18:37, Carlos Grohmann carlos.grohm...@gmail.com 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
On Fri, Dec 18, 2009 at 11:55 AM, sturlamolden sturlamol...@yahoo.nowrote:
On 17 Des, 18:37, Carlos Grohmann carlos.grohm...@gmail.com 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
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 will be the
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:
* 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)
11 matches
Mail list logo