top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Peephole optimizations on CPython?

+2 votes
120 views

http://www.python.org/workshops/1998-11/proceedings/papers/montanaro/montanaro.html

Just wanted to clarify whether CPython already includes these kind of byte code optimizations? Are all the temporary variables removed when byte code is generated?

posted Feb 17, 2014 by Seema Siddique

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+2 votes

You can check these things for yourself:

import dis
dis.dis(function)

will show you the byte code.

But in general, I would expect not. CPython (that's the Python you probably use) doesn't do a lot of optimization apart from some simple constant folding. If you're interested in optimizing Python, you should look at the JIT optimizing Python compiler, PyPy.

answer Feb 17, 2014 by Dewang Chaudhary
Similar Questions
0 votes

I'm running a box with Debian squeeze, and I just ran:

sudo aptitude install jython

which ended up installing Python 2.5:

[...]
Linking and byte-compiling packages for runtime python2.5...
Setting up python2.5 (2.5.5-11) ...

Does anyone know why CPython 2.5 is a dependency for Jython 2.5.1+ on Debian squeeze?

0 votes

I'm currently trying to make sense of Python's Timsort function. From the wikipedia page I was told the algorithm is located somewhere here: http://hg.python.org/cpython/file/default/Objects/listobject.c

So of all the functions in there, could somebody point to me which one is timsort?

+2 votes

I have an application which uses extensively python 2.7.6 (CPython).

The issue that I see is the following: "If there are only pyc files, the loading time of the application is much more than if I have pyc and py files. It is behind with 2 minutes more than if it had py files"

Do you have any idea why this is happening?

+1 vote

I have installed, de-installed and reinstalled this s/w and MySQL itself on my Win8 box. However, when I go to use it from a script, I get the following error:

"C:Python27libsite-packagesMySQLdb__init.py__", line 27 in  import _mysql
ImportError: DLL load failed: %1 is not valid Win32 application. 

I'm running Win8 which is 64-bit, Python 27, MySQL 5.5. Please help?

0 votes

I want to install sip on windows bit using python 32 bit.
I download sip from this link https://www.riverbankcomputing.com and I try to install from cmd line :

C:WINDOWSsystem32>cd C:UsersusernameDesktopsip-4.17

C:UsersusernameDesktopsip-4.17>python configure.py install
and take that error any idea ?

This is SIP 4.17 for Python 2.7.11 on win32.
Error: Unsupported macro name specified. Use the --show-build-macros flag to see a list of supported macros.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...