Skip to main content

native_jit

native_jit is a Cython-powered JIT decorator for Python functions and classes.

It tries to compile decorated objects for speed and automatically falls back to the original Python object if compilation is not available in the current environment.

Features

  • @jit for functions and classes
  • Cython compilation pipeline (.pyx -> .c -> extension module)
  • In-memory and disk cache for compiled modules
  • Concurrent compilation deduplication
  • Cross-platform compiler detection (CC / system compiler fallback)
  • Safe fallback mode: no hard failure when compilation is unavailable

Install

pip install native-jit

For local development:

pip install -e .[dev]

Quick Start

from native_jit import jit

@jit
def add(a: int, b: int) -> int:
    return a + b

print(add(1, 2))

Advanced usage:

from native_jit import jit

@jit(nopython=True)
def fast_sum(n: int) -> int:
    s = 0
    for i in range(n):
        s += i
    return s

print(fast_sum(1000000))

API

  • jit(...): decorate function/class/method
  • jit.from_pyx(func_name, pyx_code, **kwargs): compile raw Cython source
  • jit.warmup(): warm up compiler flag probing
  • jit.cache_info(): inspect cache and compiler flags
  • jit.clear_cache(disk=False): clear in-memory/disk cache

Notes on Compilers

Cython does not bundle a C compiler. A system C toolchain is still required for native compilation.

native_jit detects compiler command from:

  1. CC environment variable
  2. Python build configuration (sysconfig)
  3. common fallback commands (cc, clang, gcc, cl)

If no compiler is available, decorated code still runs with Python fallback mode.

Publish to GitHub

git init
git add .
git commit -m "chore: prepare package for release"
git branch -M main
git remote add origin https://github.com/<your-user>/<your-repo>.git
git push -u origin main

Build and Publish to PyPI

  1. Create PyPI account and API token.
  2. Export token:
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=<pypi-token>
  1. Build package:
python -m build
  1. Verify artifacts:
python -m twine check dist/*
  1. Upload to TestPyPI (recommended first):
python -m twine upload --repository testpypi dist/*
  1. Upload to PyPI:
python -m twine upload dist/*

Verify Install

pip install native-jit
python -c "from native_jit import jit; print(callable(jit))"

Metadata

Release files for native-jit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for native-jit 0.1.0
File Size Uploaded
native_jit-0.1.0.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for native-jit 0.1.0
File Interpreter ABI Platform
native_jit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / native_jit-0.1.0.tar.gz

Download URL native_jit-0.1.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9ee65038e053677fb18f953cb867ec65596ed2494c5239e733c313f524ac2d86
BLAKE2b-256 checksum
How to use checksums
744de64c66dd319a5e790de81d613b48fddbf1241e4c7ba634411dda3ca32727
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / native_jit-0.1.0-py3-none-any.whl

Download URL native_jit-0.1.0-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
792b4c0f1d61085607b659ee1146793bdeed49b395760b1f83b64286197b16ed
BLAKE2b-256 checksum
How to use checksums
6e3cdd15d17e788ab54eceedf00e4c7ff8834ff908641ed4d2f553375a2cc272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page