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/2005-September/056441.html below:

[Python-Dev] python optimization

[Python-Dev] python optimization [Python-Dev] python optimizationGreg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 16 05:55:41 CEST 2005
Brett Cannon wrote:

>>I don't know to what extent these kind of optimizations are available to
>>cpython.  For example, are constant calculations removed from loops?
> 
> If you mean ``2+3``, then yes.

Actually, no. Constant folding *could* be done, but it currently isn't:

 >>> def f():
...   return 2+3
...
 >>> import dis
 >>> dis.dis(f)
   2           0 LOAD_CONST               1 (2)
               3 LOAD_CONST               2 (3)
               6 BINARY_ADD
               7 RETURN_VALUE
               8 LOAD_CONST               0 (None)
              11 RETURN_VALUE
 >>>

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+
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