GithubHelp home page GithubHelp logo

tempbottle / falcon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rjpower/falcon

0.0 2.0 0.0 1.26 MB

C Python, made faster.

License: Apache License 2.0

Makefile 15.74% Python 11.93% C++ 66.53% C 0.62% M4 2.95% Shell 2.22%

falcon's Introduction

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/activate

python 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. Falcon then rewrites this bytecode by applying some rudimentary dataflow optimizations and executes it using direct-threaded dispatch. Falcon also stores integers directly in registers (without constructing PyInt objects) using bit tagging, 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.

falcon's People

Contributors

arne-cl avatar hydrogen18 avatar iskandr avatar kotnik avatar rjpower avatar tyilo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.