Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbdf_file type #63

Open
jagrata opened this issue Jan 22, 2024 · 1 comment
Open

sbdf_file type #63

jagrata opened this issue Jan 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jagrata
Copy link

jagrata commented Jan 22, 2024

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:

    # Open the SBDF file if necessary
    if isinstance( sbdf_file, str ):
        output_file = _pathlike_to_fileptr(sbdf_file, "wb")
    else:
        output_file = sbdf_file
@bbassett-tibco
Copy link
Collaborator

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants