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
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
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
___
Tutor maillist - Tutor@python.org
To unsubsc
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
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
[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
___
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
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
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
I have seen list comprehensions used, but have not quite got the hang of it
yet.
So, I was writing a bit of code to do some work with file directories and
decided
to give it a try as follows:
list_c = os.listdir("c:")
#first code written in the way I usually would.
dirs = []
for x in list_c:
10 matches
Mail list logo