Check out the official documentation here.
Package Extensions
Cpyte supports a package extension system that allows packages to extend the compiler with custom keywords, operators, and compiler hooks. Packages can provide:
- Custom Keywords: Add new language keywords via
package.json - Custom Operators: Define new operators for syntax extensions
- Compiler Hooks: Extend lexing, parsing, semantic analysis, and code generation
- Runtime Extensions: Add runtime code and libraries
Package Structure
Packages are stored in .cpm/modules/package_name/version/ and can include:
package.json- Extension manifest declaring capabilitiesparser_hooks.py- Custom syntax extensionssemantic_hooks.py- Custom type checking and analysis rulescodegen_hooks.py- Custom LLVM IR generationruntime_hooks.py- Runtime code and libraries*.cpy- Main package entry point*.ll- Prebuilt LLVM IR
Example Package
See examples/example_package/ for a complete example package with:
- Custom keywords:
async,await,defer - Custom operator:
~~ - Parser, semantic, codegen, and runtime hooks
Using Extension Packages
import @package_name
# Use custom keywords and syntax from the package
async def my_function() -> Promise:
# Custom syntax
defer cleanup()
return result
Examples
You'll find comprehensive examples in the examples/ directory that cover C imports, header imports, 64-bit support, and standard library usage:
| File | Description |
|---|---|
examples/c_import_example.cpy |
Importing and calling functions from C source files |
examples/example_math.c |
C source with math utility functions for the C import example |
examples/h_import_example.cpy |
Importing functions declared in C header files |
examples/example_functions.h / example_functions.c |
Header and implementation for the H import example |
examples/64bit_example.cpy |
Comprehensive int64/uint64 arithmetic, hex literals, type promotion |
examples/c_library_imports.cpy |
Using built-in C libraries (stdio, stdlib, math, string, time) |
examples/mixed_features.cpy |
Combines C imports, H imports, 64-bit, structs, pointers, linked lists |
examples/mixed_helpers.c / mixed_helpers.h |
Supporting C/header files for the mixed features example |
examples/test.cpy |
macOS event tap example that intercepts keyboard events using ApplicationServices framework |
examples/example_package/ |
Example package demonstrating extension capabilities with custom keywords, operators, and compiler hooks |
You can also import .cpy files — the examples show how to use import "other.cpy" to bring in public functions and structs from other Cpy files.
Run any example with:
cpy examples/<filename>.cpy
Note
Cpyte is experimental software. The compiler is continuously tested with fuzzing and a regression corpus, and every release is published to PyPI and Gitea.
Memory Management
Cpyte uses a concurrent tri-color garbage collector for automatic memory management. Heap-allocated objects (via new) are managed automatically — no manual free needed.
Note: The collector adds a small runtime overhead (~5-10%) compared to manual malloc/free. For performance-critical ecosystem projects or embedded use cases, this trade-off may be significant. The GC is required for safety but will slow down programs that do heavy heap allocation.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cpyte-3.2.0.tar.gz.
File metadata
- Download URL: cpyte-3.2.0.tar.gz
- Upload date:
- Size: 186.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a28f3ac71df24dcc3f0988d00b9b244b83ffe5c6c46cdb151d649e4afef20782
|
|
| MD5 |
adb77a9998cd2db11009163f789f8720
|
|
| BLAKE2b-256 |
d7cb036d36f9955365a6bb99ec01c8f245c9b85ffff99e9ee6d4e943d33bd1b1
|
File details
Details for the file cpyte-3.2.0-py3-none-any.whl.
File metadata
- Download URL: cpyte-3.2.0-py3-none-any.whl
- Upload date:
- Size: 189.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3d53b89daa6489ba1baec203c3b526e225a76c9ee8cd807d83f903564d4c14e
|
|
| MD5 |
c2c0c6e32eef4e75c566675cd6cc0cc8
|
|
| BLAKE2b-256 |
fac2695d09b6284d10ee806320d8c56c7b05616b0d02fb45456c2910d4afe0bb
|