Code Monkey home page Code Monkey logo

mypyc

Mypyc compiles Python modules to C extensions. It uses standard Python type hints to generate fast code. Mypyc uses mypy to perform type checking and type inference.

Mypyc can compile anything from one module to an entire codebase. The mypy project has been using mypyc to compile mypy since 2019, giving it a 4x performance boost over regular Python.

Features

  • Support most features in the stdlib typing module
  • Compile clean, regular-looking Python code with type annotations
  • Expressive type system, including generics, optional types, union types and tuple types
  • Powerful type inference -- no need to annotate most variables
  • All code is valid Python, and all Python editors and IDEs work just fine
  • Access to all stdlib and third-party libraries in compiled code
  • Strict runtime enforcement of type annotations for runtime type safety
  • Ahead-of-time compilation for fast program startup
  • Compiled code runs as normal Python code (compilation is optional)
  • Both static type checking (via mypy) and runtime type checking

Documentation

Documentation is available at ReadTheDocs.

Benchmarks

We track the performance of mypyc using several benchmarks. Results are updated daily to make it easy to track progress.

Questions or issues?

The mypyc issue tracker lives in this repository. You can also ask questions in our Gitter chat.

Differences from Cython

  • Write clean code without non-standard syntax, such as cpdef, or extra decorators, with good performance.
  • First-class support for type system features such as tuple types, union types and generics.
  • Variable type annotations are not needed for good performance, due to powerful type inference provided by mypy.
  • Full integration with mypy for robust and seamless static type checking.
  • Mypyc performs strict enforcement of type annotations at runtime, for better runtime type safety.

Development roadmap

These are our near-term focus areas for improving mypyc:

  • Improved compatibility with Python
  • Much faster compilation (parallel and incremental compilation, and more)
  • Usability

... and better performance (always!).

Development status

We are actively looking for early adopters! Mypyc is currently alpha software. It's only recommended for production use cases with careful testing, and if you are willing to contribute fixes or to work around issues you will encounter.

Help wanted

New contributors are very welcome! Any help in development, testing, documentation and benchmarking tasks is highly appreciated.

Useful links for contributors:

Changelog

Follow our updates on the mypy blog: https://mypy-lang.blogspot.com/

License

Mypyc and mypy are licensed under the terms of the MIT License, with portions under the Python Software Foundation license (see the file LICENSE in the mypy repository).

mypyc's Projects

mypyc icon mypyc

Compile type annotated Python to fast C extensions

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.