simple-binary-encoding icon indicating copy to clipboard operation
simple-binary-encoding copied to clipboard

Python generator implementation

Open feribg opened this issue 5 years ago • 5 comments

I just finished work on a pure python stub generator. Right now it's somewhat crude and quality of generated code can be improved upon but it's more or less fully functional. Wondering if you're interested in a PR. It's based on the Csharp generator, so it follows the single stub with multiple methods wrap_encode, wrap_decode instead of 2 classes as per the reference Java impl. It also has a couple of neat things like full type hints and usage of https://docs.python.org/3/c-api/buffer.html#bufferobjects , however they're somewhat muted because python has to cast most memory objects to int or str anyways, so heavy on allocations, a Cython impl should be trivial based on the current code though.

feribg avatar Apr 06 '19 21:04 feribg

We would be happy to discuss a PR. However we have seen partial implementations in the past go nowhere so we are only really interested in languages that will be completed and supported longer term.

We have learned over time that separating the encoding and decoding into separate classes is more appealing and results in safer code.

mjpt777 avatar Apr 07 '19 13:04 mjpt777

Let me know if I can clarify or tidy it up in some ways

feribg avatar Apr 10 '19 06:04 feribg

Any eta on python support? Is this supported https://github.com/tfgm/sbedecoder ?

sambatth avatar Mar 23 '20 17:03 sambatth

@samratbatth To be honest I haven't had time to put towards it, but if you want feel free to clone it and clean it up, it's mostly code cleanup not functional issues.

Although if im to write it up again, I would likely just wrap the C++ codecs with pybind or something like that. The struct library is slow so if we can reuse the buffers and cast to numpy types directly that will likely give you C like speed in Python.

feribg avatar Mar 23 '20 19:03 feribg

Any suggestions on implementing SBE decoder in Python for CME MDP 3.0 market data?

sahilshetty13 avatar Sep 06 '21 13:09 sahilshetty13