Conversation
|
Alternative names would be |
... and move one operator from after to before the line break.
|
I added a commit (357ef04) with a possible implementation. This provides the 3 methods This commit also removes the hard dependency on NumPy, now it is only needed if I didn't find a meaningful way to include |
|
Looks good. I don't quite like how this adds yet another layer of abstraction betwee I am worried about performance, though. The numpy import might incur a big overhead on every read/write. Did you check if this has any measurable performance impact? Also, I think we should keep numpy as a dependency. For most people, pysoundfile is not useful without numpy. Can you think of any other way to handle this? |
I did not measure this, but importing an already imported module should only add the overhead of a (successful) dictionary lookup of An alternative (but not strictly equivalent) approach would be to But I think that's much worse, because a user might have NumPy installed but might not want to use it (e.g. to avoid the load time), which wouldn't be possible with the alternative approach.
Hmmm, I only see 3 possible kinds of dependency:
Is there another way? If we keep it as hard dependency, people without NumPy will not be able to OTOH, installing NumPy with pip will not work on most systems anyway (at least that's my experience). And even if it works, it will most likely be a inferior installation (with regards to the usage of optimized libraries) compared to an installation with a package manager. I think most users will use a Python system which already has NumPy installed (like Anaconda) or they should use some other package manager to install NumPy anyway. For the Debian package, we could change the dependency from |
|
As far as I know, numpy is working on wheels. We might need to revisit this once the Python packaging ecosystem switches over to wheels ;-) |
Add low-level methods read_buffer() and write_buffer()
|
Thanks for merging! I had a quick look and it looks like there are only wheels for OSX: https://pypi.python.org/pypi/numpy We could make the dependencies OS-dependent, but I don't know if that's really a good idea. |
|
No hurry. At the moment, I agree with you that numpy is probably best installed using a package manager like conda, brew, or apt. But in a few years, who knows, maybe installing numpy won't be a problem any more, and a dependency here or there might do more good than harm. |
|
Just for the record: The Debian package changed its NumPy dependency to |
Instead of NumPy arrays, these would handle plain Python buffers.
This would allow a wider range of interoperability with Python libraries that use buffers, without forcing our users to convert their buffers into NumPy arrays.
These functions should then internally be used to implement our
read()andwrite()methods.Apart from the number of items (not frames), these methods could take one of the strings
'short','int','float','double'.They could also accept
'raw'(or'bytes'?), which would provide an alternative solution to #25.If we at some point split the implementation into several files, as suggested in https://github.com/bastibe/PySoundFile/issues/57#issuecomment-49281037, we could then create a low-level submodule which would have no dependencies on NumPy.