Py2C is an experimental project aimed at compiling Python code into native C++ code. The goal is to leverage the performance benefits of C++ while maintaining the expressiveness of Python.
This project is currently in the Alpha stage. The runtime library provides basic support for Python's dynamic typing, built-in functions, and core data structures like list and dict.
- Dynamic Type System: Implemented using
std::anyto handle Python's dynamic typing (int,float,str,list,dict). - Built-in Functions: Basic implementation of
add,len,to_string, and comparison operators (==,!=,<,<=,>,>=). - Core Data Structures:
PythonList: Supports basic list operations and comparison.PythonDict: Supports basic dictionary operations and equality comparison.
- Compilation: The project uses CMake to build the runtime library and a placeholder compiler executable.
-
Prerequisites:
- CMake (version 3.10 or higher)
- C++ compiler supporting C++20 standard (e.g., g++ 10 or higher)
-
Build:
mkdir build cd build cmake .. make -
Run Test: The
test_py_outputexecutable contains a set of unit tests for the runtime library../test_py_output
See todo.md for the detailed development plan.