Skip to content

swhitegx/Py2C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Py2C: Python to C++ Compiler (Alpha)

Project Overview

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.

Current Features

  • Dynamic Type System: Implemented using std::any to 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.

Build Instructions

  1. Prerequisites:

    • CMake (version 3.10 or higher)
    • C++ compiler supporting C++20 standard (e.g., g++ 10 or higher)
  2. Build:

    mkdir build
    cd build
    cmake ..
    make
  3. Run Test: The test_py_output executable contains a set of unit tests for the runtime library.

    ./test_py_output

Future Development

See todo.md for the detailed development plan.

About

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.

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors