Skip to main content

Python interface for cpp-pd-code-simplify with runtime C++ compilation.

Project description

cpp-pd-code-simplify-interface

cpp-pd-code-simplify-interface is a Python package for calling the cpp-pd-code-simplify C++ implementation from Python.

The package is designed for PyPI distribution:

pip install cpp-pd-code-simplify-interface

It ships the C++ source code inside the wheel and source distribution. On first use, the package compiles a cached local dynamic library through cpp-simple-interface; later calls reuse that library through ctypes. A C++14 compiler compatible with g++ must be available at runtime.

Calls use the C++ library's default preprocessing pipeline: R1-move removal followed by nugatory-crossing removal, then iterative mid-simplification.

Example

import cpp_pd_code_simplify_interface as simplify

pd_code = "PD[X[1,5,2,4],X[3,1,4,6],X[5,3,6,2]]"
result = simplify.simplify(pd_code)
print(result["final_pd_code"])

The default max_paths=-1 uses deterministic heuristic green-path sampling in the C++ backend. Use ban_heuristic=True to request exhaustive green-path enumeration for a manageable input. Use reduction_round=K to cap applied mid-simplification rounds; the default -1 runs until stable. Use verbose=True to forward C++ progress logs to stderr.

Batch use:

results = simplify.simplify_many([pd_code, "PD[]"])

To select a compiler:

CXX=clang++ python your_script.py

Windows PowerShell:

$env:CXX = "C:\path\to\g++.exe"
python your_script.py

On Windows, use a compiler whose target architecture matches Python. A 64-bit Python process needs a 64-bit compiler target.

Command-line use also supports multi-line PD-code files:

python -m cpp_pd_code_simplify_interface --pd-file inputs.pd --max-paths -1 --verbose

Build And Publish

From this directory:

poetry build
poetry publish

Use poetry publish --build to build and upload in one command.

For local testing:

poetry run python -m cpp_pd_code_simplify_interface "PD[]"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpp_pd_code_simplify_interface-0.1.3.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cpp_pd_code_simplify_interface-0.1.3.tar.gz.

File metadata

File hashes

Hashes for cpp_pd_code_simplify_interface-0.1.3.tar.gz
Algorithm Hash digest
SHA256 15c97c364644ac7eb76b7f25a0819e8a9b508607b20a46a440edbe254bd53748
MD5 7d58d75c9461f2394b13371432464959
BLAKE2b-256 d8ee28d92f1ea240737cbb91c3cb27be68a1388532e8b57b7d979f33e739cd9a

See more details on using hashes here.

File details

Details for the file cpp_pd_code_simplify_interface-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cpp_pd_code_simplify_interface-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 27aa861e001989a35f8ffb7923c9da83f1c676d1a139f3502e1d91389bc2e640
MD5 4c5b7f2fbc26d7afd442659b324e66b9
BLAKE2b-256 d0ceaa346b8bcb05ddcd7a0e88af44377798e7328537a9eb5268503da37e5e30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page