pypowsybl icon indicating copy to clipboard operation
pypowsybl copied to clipboard

Support for input/output stream

Open sylvlecl opened this issue 3 years ago • 0 comments

  • Do you want to request a feature or report a bug?

Technical improvement / feature

  • What is the current behavior?

When working with files (network files in particular), we mostly transfer file paths between python and java. It would be useful to be able to transfer the content instead.

The easy way is to transfer content as a string.

But a more efficient approach would be to be able to pass "input streams" or "output streams" from python to C.

  • What is the expected behavior?

We should be able to pass read/write functions from python to java and implement InputStream and OutputStream classes using such functions on the java side.

  • What is the motivation / use case for changing the behavior?

Using pypowsybl methods without necessarily going through files on disk, or even full file content in memory.

For example, from the python side, we could write :

with open('/file/path', 'rb') as f:
    network = pp.network.load(f)    # here file content would be read from java as an InputStream
...
with open('/file/path', 'wb') as f:    # here file content would be written from java to an OutputStream
    network.save(f)

sylvlecl avatar Jun 23 '21 15:06 sylvlecl