compilation

`goto` in Python

`goto` in Python Question: I must use goto in Python. I found entrians goto but my Python implementation (CPython 2.7.1 on Mac) does not have this module, so it doesn’t seem to be portable. It should at least work in all Python implementations which support CPython bytecode (esp. I care about CPython and PyPy). Then …

Total answers: 6

Building Python with SSL support in non-standard location

Building Python with SSL support in non-standard location Question: I need to install several Python modules on a RHEL where I don’t have root access. At least one of the modules also needs access to Python.h. In this case I find that the best thing is to install python and it dependencies in ~/local. It …

Total answers: 12

Implementing a function in Python vs C

Implementing a function in Python vs C Question: Is there a difference (in terms of execution time) between implementing a function in Python and implementing it in C and then calling it from Python? If so, why? Asked By: JohnJohnGa || Source Answers: Python (at least the “standard” CPython implementation) never actually compiles to native …

Total answers: 4

How to statically link a library when compiling a python module extension

How to statically link a library when compiling a python module extension Question: I would like to modify a setup.py file such that the command “python setup.py build” compiles a C-based extension module that is statically (rather than dynamically) linked to a library. The extension is currently dynamically linked to a number of libraries. I …

Total answers: 3

How can I check the syntax of Python script without executing it?

python: how to check syntax of python file/script without executing it? Question: I used to use perl -c programfile to check the syntax of a Perl program and then exit without executing it. Is there an equivalent way to do this for a Python script? Asked By: Eugene Yarmash || Source Answers: You can use …

Total answers: 9

Can I somehow "compile" a python script to work on PC without Python installed?

Can I somehow "compile" a python script to work on PC without Python installed? Question: So I have a Python script: myscript.py I am executing it like this: python D:myscript.py However, I must have Python installed and included in the PATH environment variable for that to work. Is it somehow possible to “bundle” Python executable …

Total answers: 5

Can Cython compile to an EXE?

Can Cython compile to an EXE? Question: I know what Cythons purpose is. It’s to write compilable C extensions in a Python-like language in order to produce speedups in your code. What I would like to know (and can’t seem to find using my google-fu) is if Cython can somehow compile into an executable format …

Total answers: 4

Compile the Python interpreter statically?

Compile the Python interpreter statically? Question: I’m building a special-purpose embedded Python interpreter and want to avoid having dependencies on dynamic libraries so I want to compile the interpreter with static libraries instead (e.g. libc.a not libc.so). I would also like to statically link all dynamic libraries that are part of the Python standard library. …

Total answers: 4

Why compile Python code?

Why compile Python code? Question: Why would you compile a Python script? You can run them directly from the .py file and it works fine, so is there a performance advantage or something? I also notice that some files in my application get compiled into .pyc while others do not, why is this? Asked By: …

Total answers: 10