Jul-18-2023, 02:16 PM
(This post was last modified: Jul-18-2023, 02:59 PM by deanhystad.)
When you create a wheel (a package distribution that you can install using pip), you include instructions on how to handle things like installing libraries. You could inlcude your C code as source, and have the wheel compile the code to make the library. This is frequently done. The result is a portable, native library.
You may not like the answer, but this is how this kind of thing is done in Python.
Another option is to piggyback off one of the packages that calls a C library to do math, line numpy.
You may not like the answer, but this is how this kind of thing is done in Python.
Another option is to piggyback off one of the packages that calls a C library to do math, line numpy.
import numpy as np x = np.ubyte(42) y = x for _ in range(10): print(y) y += x
Output:42
84
126
168
210
252
c:\Users\djhys\Documents\python\musings\junk.py:7: RuntimeWarning: overflow encountered in scalar add
y += x
38
80
122
164
The addition is actually happening in a numpy C library. You can turn off the warning. Now your packages forces users to install numpy. Which, by the way, you can make happen automatically by adding that package to your wheel.