Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rjpower/falcon
C Python, made faster.
https://github.com/rjpower/falcon
Last synced: about 1 month ago
JSON representation
C Python, made faster.
- Host: GitHub
- URL: https://github.com/rjpower/falcon
- Owner: rjpower
- License: apache-2.0
- Created: 2012-12-07T19:37:09.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-10-20T14:50:37.000Z (about 9 years ago)
- Last Synced: 2024-07-31T22:43:40.610Z (5 months ago)
- Language: C++
- Size: 1.23 MB
- Stars: 344
- Watchers: 26
- Forks: 19
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Falcon
======CPython, made faster.
Falcon is an extension module for Python which implements an optimized, register machine based interpreter,
inside of your interpreter. You specify which functions you want Falcon to wrap (or your entire module), and
Falcon takes over execution from there.Performance improvements vary from not at all (sorry) to up to 3 times faster (yay!).
### Getting the code:
git clone https://github.com/rjpower/falcon
cd falcon# optional, setup virtualenv
virtualenv .
source bin/activatepython setup.py develop
python test/test_math.py### Using Falcon:
import falcon
@falcon.wrap
def my_slow_function()
..._or_
python -m falcon my_module.py
Try it out, and let us know what you think!
### Questions
**What is Falcon and how is it different from CPython?**
The usual Python implementation (called CPython) compiles Python syntax to a stack bytecode.
Falcon translates CPython's stack-based representation to a
[register-based virtual machine](http://stackoverflow.com/questions/11120343/advantages-of-stack-based-bytecodes-or-infinite-register-machines).
Falcon then rewrites this bytecode by applying some rudimentary dataflow optimizations and executes it using [direct-threaded dispatch](https://blog.mozilla.org/dmandelin/2008/06/03/squirrelfish/).
Falcon also stores integers directly in registers (without constructing PyInt objects) using [bit tagging](http://mail.python.org/pipermail/python-dev/2004-July/046139.html), which
can yield significant speed improvements on arithmetic-heavy code.**How is Falcon different from PyPy?**
PyPy is a tracing compiler, whereas Falcon is just an efficient interpreter implementation.
PyPy might speed up your code by several orders of magnitude but it will also choke on any extension code
which depends on the Python C API. Falcon, on the other hand, aims only for modest performance gains but preserves
the PyObject data representation necessary to avoid breaking extension modules.**Does Falcon support all of Python?**
Not yet! Lots of constructs (like catching exceptions, constructing objects, etc...) aren't implemented in the Falcon virtual machine.
However, this doesn't mean that programs which use these constructs won't run. Any missing functionality is routed through the Python C API,
foregoing any potential performance benefit you might have gotten from Falcon. So, though Falcon isn't a complete Python implementation,
it should still run all of your code. If you try Falcon and it crashes on some program then you've encountered a bug and should let us know.