A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-March/042925.html below:

[Python-Dev] New opcode to simplifiy/speedup list comprehensions

[Python-Dev] New opcode to simplifiy/speedup list comprehensions [Python-Dev] New opcode to simplifiy/speedup list comprehensionsRaymond Hettinger python at rcn.com
Sat Mar 6 08:53:56 EST 2004
> >>> def f(x):
> 	y = [i+i for i in x]
> 
> >>> dis(f)
>   2           0 BUILD_LIST               0
>               3 DUP_TOP
>               4 LOAD_ATTR                0 (append)    <-- delete this
> line
>               7 STORE_FAST               3 (_[1])
>              10 LOAD_FAST                0 (x)
>              13 GET_ITER
>         >>   14 FOR_ITER                20 (to 37)
>              17 STORE_FAST               2 (i)
>              20 LOAD_FAST                3 (_[1])
>              23 LOAD_FAST                2 (i)
>              26 LOAD_FAST                2 (i)
>              29 BINARY_ADD
>              30 CALL_FUNCTION            1              --> replace
with
> LIST_APPEND
>              33 POP_TOP                                 <-- delete
this
> line
>              34 JUMP_ABSOLUTE           14
>         >>   37 DELETE_FAST              3 (_[1])


P.S.  The patch also removes the DELETE_FAST at position 37


>              40 STORE_FAST               1 (y)
>              43 LOAD_CONST               0 (None)
>              46 RETURN_VALUE


Raymond Hettinger


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4