Skip to main content

C++ DSP Extensions for Python.

Project description

python-cxx

uv Python Version from PEP 621 TOML PyPI - Implementation Build PyPI - Wheel GitHub License

C/C++ DSP Extensions for Python.

Building the foundation for a fast, reliable, easy-to-use signal processing toolset.

This package is about real-world utility, learning, and most of all fun!

Installation & Usage

pip install python-cxx

Once the package has been installed you can run the example with

python-cxx-example

If successful, you should see something like this

---------------------------------------------------------
Hello from python_cxx!!!
A C++ compiled extension that can operate in Python.
For example, given a list [1, 2, 3]...one can use:
---------------------------------------------------------
* Typecasting to e.g. square: python_cxx.IntVector([1, 4, 9])
* Binding to e.g. double: python_cxx.IntVector([2, 4, 6])
* Or wrap an operation like decrement: [0, 1, 2]!
Executing a C++ class method on [1. 1. 1. 1. 1.] gives:
Exponential average: [0.9     0.99    0.999   0.9999  0.99999]

Benchmark Results
-----------------
* Ran 100 trials 5 times.
* Time of one independent trial: 2.92 msec
* Best time of subsequent trials: 2.7 msec
* Worst time of subsequent trials: 2.92 msec
* Best speed: 152 Mitems / sec
* Worst speed: 140 Mitems / sec

Experiment with the example script (python-cxx/example.py), use with the interpreter, or get the source and add your own features!

>>> import numpy as np
>>> from python_cxx import decrement_it
>>> x = [1, 2, 3]
>>> decrement_it(x)
[0, 1, 2]

Source Installation & Development

Install

Get uv

curl -LsSf https://astral.sh/uv/install.sh | sh

Get the code and go to the project directory

git clone https://github.com/hunterdsp/python-cxx.git && cd python-cxx

Synchronize dependencies and install

uv sync

Develop

  • Edit the code
  • Add testing
  • Commit!
  • Synchronize: uv sync
  • Run scripts e.g.: uv run --no-editable python-cxx-example
  • Ensure ALL tests pass: uvx pytest
  • Repeat until you make it here with no failures
  • Submit a pull-request

... more coming soon ... Have Fun!!!

Debugging

Create a debug environment and install ALL dependencies adding meson-python

uv venv .venv.debug --clear
. .venv.debug/bin/activate
uv pip install . meson-python

Build the extension with debug symbols

uv pip install --editable . --no-build-isolation \
    -Csetup-args=-Dbuildtype=debug \
    -Cbuild-dir=build-dbg

Attach to the example with gdb and set a breakpoint on the step method

gdb --args python3.12 -c "from python_cxx_example import main; main()"
break step
run

You should see the debugger stop on the first call to step() like so

[New Thread 0x7fffcddf26c0 (LWP 612534)]
[New Thread 0x7fffcd5f16c0 (LWP 612539)]
Downloading separate debug info for ...

---------------------------------------------------------
Hello from python_cxx!!!
A C++ compiled extension that can operate in Python.
For example, given a list [1, 2, 3]...one can use:
---------------------------------------------------------
* Typecasting to e.g. square: python_cxx.IntVector([1, 4, 9])
* Binding to e.g. double: python_cxx.IntVector([2, 4, 6])
* Or wrap an operation like decrement: [0, 1, 2]!
Executing a C++ class method on [1. 1. 1. 1. 1.] gives:

Thread 1 "python3.12" hit Breakpoint 1.1, ExpAverage::step (this=0x7ffff49cd708, x=...) at ../src/array.cpp:18
18           void step(nanobind::ndarray<nanobind::c_contig, nanobind::device::cpu> x) {
(gdb) 

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

python_cxx-0.1.0b23.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

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

python_cxx-0.1.0b23-cp314-cp314t-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

python_cxx-0.1.0b23-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (72.3 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

python_cxx-0.1.0b23-cp314-cp314-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

python_cxx-0.1.0b23-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (73.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

python_cxx-0.1.0b23-cp313-cp313-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

python_cxx-0.1.0b23-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (73.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

python_cxx-0.1.0b23-cp312-cp312-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

python_cxx-0.1.0b23-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (73.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file python_cxx-0.1.0b23.tar.gz.

File metadata

  • Download URL: python_cxx-0.1.0b23.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23.tar.gz
Algorithm Hash digest
SHA256 802a44686931f1a0eef7708041120084bf8fbbf72b5328fc69055fdcd6320dbb
MD5 367426c946c01391864d8c5ff4712119
BLAKE2b-256 4093ea8a1ff2a0bce817dd4f07ddbb4879029812953dcf473ed3390c07c9e900

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp314-cp314t-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c3c55f057b029465f7d1094e08cccb197b6d1623e459792ac4a3474d1fb88f6b
MD5 a9012ad641b6fbb391bd27fe550cc46f
BLAKE2b-256 22f1bce21811d751254d3432149622db7a27519744123c1316bba97cdc488774

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 72.3 kB
  • Tags: CPython 3.14t, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ed9110be413c7226d8bb664dfd82eebbf94fc94d46051ca32788ac36ba49dc3
MD5 69d5fbe89b3fadda74de30203061e465
BLAKE2b-256 33316fee7be12d1d000c355ac1a0b4b93fec9373ca035484230ab9ab72353dba

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp314-cp314-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 91d3b9af35ee2234b79a3e2bf11f715b27c7637cad213a75506659094af00a7f
MD5 773b2c5b5969591a135581c871f557e6
BLAKE2b-256 b26c349bc206966b629d8ba89248a909f07548138f9c3504c0034550d60cc75f

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 73.0 kB
  • Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 993450a5f27b3ec5108dd39ccbe66115f32e765edb000933ee15255eeb84ce46
MD5 91ae958d69e13efa9f3df51d30b669cf
BLAKE2b-256 e40f371c98ac6d0758afbc50410192e3c79a1c3b42f09a60d7b127dbbb8fb68f

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp313-cp313-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 568d56f2d26734561ce23589b95822151398aea42d817691ef5a67f77a72e478
MD5 dcf147c2b7c79186edf79ed26ee857c8
BLAKE2b-256 4017a0039bc4d9a9c27a8d762fb63b301764b929cf61b3c661105014233d196c

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 73.0 kB
  • Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 617c321b37a57baad7f5314b533380d0a43b5726d38949240c53f9221a6f6bcb
MD5 0774a13f30e6e9a2ad7f3975016cb330
BLAKE2b-256 90bdab5ef7b70ad028d6b7af3f38d34e18f0cff6d53d47b8dbbe0c7f72b6e1e1

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp312-cp312-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e85b9858220a14bdb8315f58b0d24bb4c998a886ee7212e88aaf64380ed3e819
MD5 7d80fae6d76eb3b40ca329aaf61d4a81
BLAKE2b-256 9d90e6f78329d107ad56f8c0f801f155651c7101a03fcdda22b77e7762d19154

See more details on using hashes here.

File details

Details for the file python_cxx-0.1.0b23-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: python_cxx-0.1.0b23-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 73.0 kB
  • Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_cxx-0.1.0b23-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 17904d4b90fabc88cd5799800690fb0db7c16d0af29434ced83be702bf01a8a6
MD5 2543e42ac3f50f631e4c753700bea6fb
BLAKE2b-256 5ee3ad87bc5f6d5ac5e6f5aab407b7bc84205cb74e70f58e5371f5310c31e395

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