Re: [Tutor] list comprehension efficiency

2012-02-18 Thread Steven D'Aprano
Bill Allen wrote: Generally speaking, are list comprehensions more efficient that the equivalent for loop with interior conditionals for a given task? Do they compile down to the same Python byte code? It depends, and no. For-loops are more general, so there are loops that can't be written as

Re: [Tutor] list comprehension efficiency

2012-02-18 Thread Mark Lawrence
On 19/02/2012 01:31, Bill Allen wrote: Generally speaking, are list comprehensions more efficient that the equivalent for loop with interior conditionals for a given task? Do they compile down to the same Python byte code? Thanks, Bill Allen ___ T

Re: [Tutor] list comprehension, efficiency?

2010-10-03 Thread bob gailer
On 10/2/2010 8:02 PM, Steven D'Aprano wrote: On Sun, 3 Oct 2010 01:17:39 am bob gailer wrote: I ran dis on a for loop and the equivalent comprehension. I was surprised to see almost identical code. I had assumed (and now wish for) that a comprehension would be a primitive written in C and th

Re: [Tutor] list comprehension, efficiency?

2010-10-02 Thread Steven D'Aprano
On Sun, 3 Oct 2010 01:17:39 am bob gailer wrote: > I ran dis on a for loop and the equivalent comprehension. > > I was surprised to see almost identical code. > > I had assumed (and now wish for) that a comprehension would be a > primitive written in C and thus much faster! How could it be? A lis

Re: [Tutor] list comprehension, efficiency?

2010-10-02 Thread bob gailer
[snip] I ran dis on a for loop and the equivalent comprehension. I was surprised to see almost identical code. I had assumed (and now wish for) that a comprehension would be a primitive written in C and thus much faster! -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] list comprehension, efficiency?

2010-09-28 Thread Bill Campbell
On Tue, Sep 28, 2010, Lie Ryan wrote: >On 09/28/10 13:57, Bill Allen wrote: >> I can now see that quite a bit of the code I write dealing with lists >> can be done with list >> comprehensions. My question is this, is the list comprehension styled >> code generally >> more efficient at runtime? I

Re: [Tutor] list comprehension, efficiency?

2010-09-28 Thread Steven D'Aprano
On Tue, 28 Sep 2010 01:57:23 pm Bill Allen wrote: > I can now see that quite a bit of the code I write dealing with lists > can be done with list > comprehensions. My question is this, is the list comprehension > styled code generally > more efficient at runtime? If so, why? List comprehensio

Re: [Tutor] list comprehension, efficiency?

2010-09-27 Thread Lie Ryan
On 09/28/10 13:57, Bill Allen wrote: > I can now see that quite a bit of the code I write dealing with lists > can be done with list > comprehensions. My question is this, is the list comprehension styled > code generally > more efficient at runtime? If so, why? Yes, because the looping in list