top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Peephole optimizations on CPython?

+2 votes
326 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 LinkedIn 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?

+2 votes

I want to use some loop optimizations. I have build GCC-4.8.1 using gmp 5.1.3, mpfr 3.1.2, mpc 1.0.1, cloog 0.18.0 and isl 0.11.1. I tried optimization flags -floop-interchange and -floop-block. I don't find any changes in the optimized code.

Are graphite loop transforms implemented in GCC-4.8.1. Should I configure and build GCC in a different way.

...