Tracing based copy-and-patch compiler for Python
Go to file
Nicolas Kruse ac6854ff9b test stencils and aux functions added, including test 2025-10-26 16:08:45 +01:00
.github/workflows ci updated to improve runtime 2025-10-26 14:08:48 +01:00
notes ms_abi added 2025-10-07 23:13:18 +02:00
src test stencils and aux functions added, including test 2025-10-26 16:08:45 +01:00
stencils test stencils and aux functions added, including test 2025-10-26 16:08:45 +01:00
tests test stencils and aux functions added, including test 2025-10-26 16:08:45 +01:00
tools extract_code tool: added patching of function call relocations 2025-10-26 15:19:38 +01:00
.flake8 code style fixed 2025-10-18 23:20:27 +02:00
.gitignore file names adjusted 2025-10-08 22:59:51 +02:00
LICENSE readme and license updated 2025-09-29 23:11:54 +02:00
README.md readme updated 2025-10-15 22:56:59 +02:00
pyproject.toml updated stencil generation 2025-10-23 17:23:47 +02:00
setup.py setup.py fixed 2025-10-04 22:58:49 +02:00

README.md

State of the project

Development is in a very early stage. Only very few components are in a working state.

Introduction

Copapy is a python based embedded domain specific language (eDSL) with a copy & patch compiler. It compiles to machine code. It uses the python interpreter for compilation. It generates a directed graph of variables and operations. The compiler generates machine code by composing pre-compiled stencils derived from C code with gcc -O3.

For code execution a executable or library receives the composed machine code, data and patch instructions. The patch instructions are used to correct memory address offsets.

The Project targets applications that profit from fast implementation (e.g. prototyping) and require realtime with low latency as well as minimizing risk of implementation errors not cached during compile time. This applies primarily for applications interfacing hardware, where runtime errors might lead to physical damage. For example robotics, embedded systems and control systems.

The language aims to be:

  • Fast to write
  • Easy to read
  • Type safe
  • Having a predictable runtime
  • Turing-complete only during compile time
  • No runtime errors
  • Immutable types

How it works

Compilation

The Compilation step starts with the directed graph of variables and operations generated by the python interpreter.

Tooling

Because the language is an embedded language, it can relay heavily on python tooling. While copapy is static typed, it uses Python to derive types during compile time wherever possible. It can get full benefit from python type checkers, to catch type errors even before compilation. Python and Copapy code can be combined seamlessly. Python acts as macro-language for the Copapy program. However, the project is designed in a way that the distinction has typically not to be considered by the programmer.

License

This project is licensed under the MIT License - see the LICENSE file for details.