mypyc VS pex

Compare mypyc vs pex and see what are their differences.

mypyc

Compile type annotated Python to fast C extensions (by mypyc)

pex

A tool for generating .pex (Python EXecutable) files, lock files and venvs. (by pex-tool)
Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
mypyc pex
25 9
1,667 2,454
1.3% 0.8%
0.0 8.9
about 1 year ago 5 days ago
Python
- Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

mypyc

Posts with mentions or reviews of mypyc. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-05-21.
  • Making use of type hints
    1 project | /r/learnpython | 10 Dec 2023
  • Writing Python like it's Rust
    10 projects | news.ycombinator.com | 21 May 2023
    That would be interesting! You might already be aware. But there's mypyc[0], which is an AOT compiler for Python code with type hints (that, IIRC, mypy uses to compile itself into a native extension).

    Wanted to give you a head-start on the lit-review for your students I guess :)

    [0] https://github.com/mypyc/mypyc

  • The different uses of Python type hints
    6 projects | news.ycombinator.com | 15 Apr 2023
    https://github.com/mypyc/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.

    I have not experience a 4x boost, rather between 1.5x and 2x. I guess it depends on the code.

  • The Python Paradox
    7 projects | news.ycombinator.com | 26 Jan 2023
    Funny how emergence works with tools. Give a language too few tools but viral circumstances - the ecosystem diverges (Lisps, Javascript). Give it too long an iteration time but killer guarantees, you end up with committees. Python not falling into either of these traps should be understood as nothing short of magic in emergence.

    I only recently discovered that python's reference typechecker, mypy, has a small side project for typed python to emit C [1], written entirely in python. Nowadays with python's rich specializer ecosystem (LLVM, CUDA, and just generally vectorized math), the value of writing a small program in anything else diminishes quickly.

    Imagine reading the C++wg release notes in the same mood that you would the python release notes.

    [1] https://github.com/mypyc/mypyc

  • Codon: A high-performance Python compiler
    12 projects | news.ycombinator.com | 8 Dec 2022
    > Note that the mypyc issue tracker lives in this repository! Please don't file mypyc issues in the mypy issue tracker.

    See https://github.com/mypyc/mypyc/blob/master/show_me_the_code....

  • ELI5: Can’t one write a compiler for Python and make everything go brrrr?
    1 project | /r/Python | 3 Nov 2022
    And mypyc https://github.com/mypyc/mypyc
  • Is it time for Python to have a statically-typed, compiled, fast superset?
    3 projects | /r/Python | 29 Sep 2022
    More recent approaches include mypyc which is (on the tin) quite close to what you describe, and taichi that lives in between.
  • Pholyglot version 0.0.0 (PHP to PHP+C polyglot transpiler)
    1 project | /r/PHP | 1 Sep 2022
    Have you encountered mypyc?
  • Python 3.11 is 25% faster than 3.10 on average
    13 projects | news.ycombinator.com | 6 Jul 2022
    https://github.com/mypyc/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.

  • Comparing implementations of the Monkey language VIII: The Spectacular Interpreted Special (Ruby, Python and Lua)
    2 projects | /r/Python | 4 Jun 2022
    Regarding the large execution time mentioned in your article, I discovered (mypyc)[https://github.com/mypyc/mypyc] on this subreddit in a post from the black formatter team https://www.reddit.com/r/Python/comments/v2009i/im_that_person_who_got_black_compiled_with_mypyc/?utm_medium=android_app&utm_source=share

pex

Posts with mentions or reviews of pex. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-06-15.
  • Our Plan for Python 3.13
    10 projects | news.ycombinator.com | 15 Jun 2023
    We get (very) close to cross-environment reproducible builds for Python with https://github.com/pantsbuild/pex (via Pants). For instance, we build Linux x86-64 artifacts that run on AWS Lambda, and can build them natively on ARM macOS.

    This is not raw requirements.txt, but isn’t too far off: Pants/PEX can consume one to produce a hash-pinned lock file.

  • Is it possible pickle a function with its dependencies?
    4 projects | /r/Python | 6 May 2023
    You should look into pex, or it’s parent build system pants. A PEX (Python EXecutable) file can package up all your code including dependencies and run on another machine of similar OS with just an available compatible interpreter.
  • Pex: Python EXecutable
    1 project | news.ycombinator.com | 7 Mar 2023
  • security risks in python libs
    1 project | /r/learnpython | 12 Sep 2022
    For well-supported libraries, pip-audit might do the trick. Where I've worked, we have used a central build system with library version enforcement. The build system produces a deployable archive, like PEX or similar. Rock-solid tests and sandbox validation environments provide good paths for version upgrades. Restricting libraries to a small set, making sure those repos remain actively developed, performing audits and centralizing builds has helped organizations I've worked in keep on top of potential security issues.
  • My latest blogpost, python packaging has moved forward, but we're still missing a crucial part - what do you think?
    1 project | /r/Python | 29 Jan 2022
  • PyBake: Create single file standalone Python scripts with builtin frozen file system
    2 projects | /r/Python | 23 Jan 2022
  • I am frustrated with packaging python, please educate me.
    2 projects | /r/Python | 16 Nov 2021
  • A function decorator that rewrites the bytecode to enable goto in Python
    5 projects | news.ycombinator.com | 20 Sep 2021
    Don't know if I agree about the goto thing, but there are actually a number of options now for delivering varying degrees of self-contained Python executable.

    When I evaluated the landscape a few years ago, I settled on PEX [1] as the solution that happened to fit my use-case the best— it uses a system-provided Python + stdlib, but otherwise brings everything (including compiled modules) with it in a self-extracting executable. Other popular options include pyinstaller and cx_freeze, which have different tradeoffs as far as size, speed, convenience, etc.

    [1]: https://github.com/pantsbuild/pex

  • Mypyc: Compile type-annotated Python to C
    6 projects | news.ycombinator.com | 23 Feb 2021
    Somewhat related, I had a devil of a time a little bit ago trying to ship a small Python app as a fully standalone environment runnable on "any Linux" (but for practical purposes, Ubuntu 16.04, 18.04, and 20.04). It turns out that if you don't want to use pip, and you don't want to build separate bundles for different OSes and Python versions, it can be surprisingly tricky to get this right. Just bundling the whole interpreter doesn't work either because it's tied to a particular stdlib which is then linked to specific versions of a bunch of system dependencies, so if you go that route, you basically end up taking an entire rootfs/container with you.

    After evaluating a number of different solutions, I ended up being quite happy with pex: https://github.com/pantsbuild/pex

    It basically bundles up the wheels for whatever your workspace needs, and then ships them in an archive with a bootstrap script that can recreate that environment on your target. But critically, it natively supports the idea of targeting multiple OS and Python versions, you just explicitly tell it which ones to include, eg:

        --platform=manylinux2014_x86_64-cp-38-cp38   # 16.04

What are some alternatives?

When comparing mypyc and pex you can also consider the following projects:

Cython - The most widely used Python to C compiler

setup.py - 📦 A Human's Ultimate Guide to setup.py.

mypy - Optional static typing for Python

python-goto - A function decorator, that rewrites the bytecode, to enable goto in Python

beartype - Unbearably fast near-real-time hybrid runtime-static type-checking in pure Python.

pyBake - Create single file standalone Python scripts with builtin frozen file system

CPython - The Python programming language

plusplus - Enables increment operators in Python using a bytecode hack

pyccel - Python extension language using accelerators

typed_python - An llvm-based framework for generating and calling into high-performance native code from Python.

typeguard - Run-time type checker for Python

mypyc-benchmark-results - Mypyc benchmark result data