Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Compile time evaluation of dictionaries
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Gerald Britton, post: 4193207"] Today I noticed that an expression like this: "one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two": "can be as bad as one"} could be evaluated at compile time, but is not: .... '"one:%(one)s two:%(two)s" % {"one": "is the loneliest number", "two": "can be as bad as one"}', .... '','exec')) 1 0 LOAD_CONST 0 ('one:%(one)s two:%(two)s') 3 BUILD_MAP 2 6 LOAD_CONST 1 ('is the loneliest number') 9 LOAD_CONST 2 ('one') 12 STORE_MAP 13 LOAD_CONST 3 ('can be as bad as one') 16 LOAD_CONST 4 ('two') 19 STORE_MAP 20 BINARY_MODULO 21 POP_TOP 22 LOAD_CONST 5 (None) 25 RETURN_VALUE Any idea why Python works this way? I see that, in 3.2, an optimization was done for sets (See "Optimizations" at [URL]http://docs.python.org/py3k/whatsnew/3.2.html[/URL]) though I do not see anything similar for dictionaries. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Compile time evaluation of dictionaries
Top