pyzmq/examples/cython
Min RK 678da52f26
ignore weird typecheck on free-threaded
2024-08-02 14:36:43 +02:00
..
.gitignore add Cython example 2020-02-25 11:25:54 +01:00
README.md adopt pydata-sphinx-theme 2022-03-02 10:22:14 +01:00
cyzmq.pyx run pre-commit (isort, pyupgrade) 2021-12-07 14:44:16 +01:00
example.py more types! 2022-01-11 15:49:04 +01:00
setup.py ignore weird typecheck on free-threaded 2024-08-02 14:36:43 +02:00

README.md

Cython example

pyzmq 19 improved the Cython interface for pyzmq, allowing easier access to libzmq.

When using pyzmq, you can:

cimport zmq

or use the underlying wrapped libzmq as

from zmq cimport libzmq

which exposes various functions and type definitions.

The setup.py file includes examples of what's needed to build a package that uses the Cython exports, mainly the use of include_dirs=zmq.get_includes() which helps Cython find the zmq definitions.

To use this example:

python setup.py build_ext --inplace
python example.py -n 100000

which will give measurements of throughput with the Python API and calling the underlying API via Cython, e.g.

Sending 5000000 messages on tcp://127.0.0.1:5555 with Cython
Cython:    2061989 msgs/sec
Sending 5000000 messages on tcp://127.0.0.1:5555 with Python
Python:     857856 msgs/sec