Open jagrata opened 8 months ago
Hi, @jagrata! The reason the SBDF module behaves like this (i.e., working with paths instead of any Python io
objects) is that the implementation is using a native C library for SBDF operations that uses the C standard-IO functions (fopen
/fread
/fwrite
/et al), which have no easy way to extend to working with io
objects. Any support would be almost exactly like what you described: using tempfile.NamedTemporaryFile
to create a temp file, export the data to it with sbdf.export_data()
, rewind the temp file, and read it into the io.BytesIO
object. Directly updating the native library to have a level of abstraction to allow what you is looking for might also have the effect of impacting read/write performance (losing perf that was the primary reason for using the native library).
In the sbdf class, on line 1888 there is the presumption that the sbdf_file provided is a string filename. One might like to use the function by passing in a io.BytesIO object to avoid having to create a file and then just read back the contents.
Can we update it to allow file-like objects be passed in in place of filenames?
For example, line 1888 in sbdf.pyx could reflect something like this: