On Thu, May 19, 2011 at 7:34 AM, Victor Stinner
victor.stin...@haypocalc.com wrote:
But it is slower whereas I read somewhere than generators are faster
than loops.
Are you sure it wasn't that generator expressions can be faster than
list comprehensions (if the memory savings are significant)?
Le jeudi 19 mai 2011 à 10:47 +1200, Greg Ewing a écrit :
Victor Stinner wrote:
squares = (x*x for x in range(1))
What bytecode would you optimise that into?
I suppose that you have the current value of range(1) on the stack:
DUP_TOP; BINARY_MULTIPLY; gives you the square. You
Le mercredi 18 mai 2011 à 21:44 -0400, Terry Reedy a écrit :
On 5/18/2011 5:34 PM, Victor Stinner wrote:
You initial example gave me the impression that the issue has something
to do with join in particular, or even comprehensions in particular. It
is really about for loops.
dis('for
Victor Stinner wrote:
I suppose that you have the current value of range(1) on the stack:
DUP_TOP; BINARY_MULTIPLY; gives you the square. You don't need the x
variable (LOAD_FAST/STORE_FAST).
That seems far too special-purpose to be worth it to me.
--
Greg
On Wed, May 18, 2011 at 2:34 PM, Victor Stinner
victor.stin...@haypocalc.com wrote:
Le mercredi 18 mai 2011 à 16:19 +0200, Nadeem Vawda a écrit :
I'm not sure why you would encounter code like that in the first place.
Well, I found the STORE_FAST/LOAD_FAST issue while trying to optimize
the
On 5/18/2011 10:19 AM, Nadeem Vawda wrote:
I'm not sure why you would encounter code like that in the first place.
Surely any code of the form:
''.join(c for c in my_string)
would just return my_string? Or am I missing something?
You might more-or-less legitimately encounter it if the
2011/5/18 Victor Stinner victor.stin...@haypocalc.com:
Hi,
''.join(c for c in 'abc') and ''.join([c for c in 'abc']) do create a
temporary c variable. In this case, the variable is useless and requires
two opcodes: STORE_FAST(c), LOAD_FAST(c). The variable is not available
outside the list
On Wed, May 18, 2011 at 10:21 PM, Victor Stinner
victor.stin...@haypocalc.com wrote:
What do you think? Is it useless and/or stupid?
I wouldn't call it useless or stupid - merely lost in the noise. In
small cases, I expect it would be swamped completely by the high fixed
overhead of entering the
On Wed, May 18, 2011 at 2:21 PM, Victor Stinner
victor.stin...@haypocalc.com wrote:
''.join(c for c in 'abc') and ''.join([c for c in 'abc']) do create a
temporary c variable.
I'm not sure why you would encounter code like that in the first place.
Surely any code of the form:
''.join(c for
On 5/18/2011 10:19 AM, Nadeem Vawda wrote:
I'm not sure why you would encounter code like that in the first place.
Surely any code of the form:
''.join(c for c in my_string)
would just return my_string? Or am I missing something?
Good question. Anything useful like '-'.join(c for c in
Le mercredi 18 mai 2011 à 16:19 +0200, Nadeem Vawda a écrit :
I'm not sure why you would encounter code like that in the first place.
Well, I found the STORE_FAST/LOAD_FAST issue while trying to optimize
the this module which reimplements rot13 using a dict in Python 3:
d = {}
for c in (65,
Hi,
2011/5/18 Terry Reedy tjre...@udel.edu:
On 5/18/2011 10:19 AM, Nadeem Vawda wrote:
I'm not sure why you would encounter code like that in the first place.
Surely any code of the form:
''.join(c for c in my_string)
would just return my_string? Or am I missing something?
Good
Victor Stinner wrote:
squares = (x*x for x in range(1))
What bytecode would you optimise that into?
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
On 5/18/2011 5:34 PM, Victor Stinner wrote:
You initial example gave me the impression that the issue has something
to do with join in particular, or even comprehensions in particular. It
is really about for loops.
squares = (x*x for x in range(1))
dis('for x in range(3): y =
On 5/18/2011 5:37 PM, Amaury Forgeot d'Arc wrote:
Hi,
2011/5/18 Terry Reedytjre...@udel.edu:
On 5/18/2011 10:19 AM, Nadeem Vawda wrote:
I'm not sure why you would encounter code like that in the first place.
Surely any code of the form:
''.join(c for c in my_string)
would just return
15 matches
Mail list logo