I need to use a function in numpy
package, say numpy.random.choice
(another Python lib function random.choice
samples the list uniformly while I want it to do that from some discrete distributions).
My program will be distributed to a lot of people to develop and test. So that means they should also install numpy
before they are able to run the code. I'm now trying to find a way to get rid of installing the whole numpy library.
Definitely rewriting the function myself is a solution (for example using alias method). But I'm wondering that is there a way that I can only install the part of numpy
related to numpy.random.choice
?
This is probably not worth the hassle but it's up to you to make that trade-off. numpy.random.choice
is not implemented in Python but in a .pyx
file which needs to be compiled to C using Cython.
You could refactor it and construct a new package which implements only that functionality (possibly with a few related data structures). But with recent improvements with Python wheels files installation of numpy
should be much easier than in the past. So I reckon it's easier to install numpy
as it is and accept that you have it as a dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With