ionelmc / python-hunter

Hunter is a flexible code tracing toolkit.
https://python-hunter.readthedocs.io/
BSD 2-Clause "Simplified" License
794 stars 46 forks source link

Question: Serializer of hunter.Event. Maybe to JSON? #102

Closed guettli closed 3 years ago

guettli commented 3 years ago

@ionelmc Hi,

I would like to serialize hunter.Event to JSON. And later create HTML from the JSON.

Before I waste too much time re-inventing this, I would like to ask: Is there already a serializer you know?

thank you for this great library!

ionelmc commented 3 years ago

Well currently there's no support but there's some discussion: https://github.com/ionelmc/python-hunter/issues/74

It's possible to implement now I believe, it's just a matter of figuring the equivalent for the __reduce__/__settate__ in the Cython implementation and implementing said boilerplate for Events. I mean it's just the events to serialize (which are pretty flat) so it's not a huge amount of work.

For json I believe you could call __reduce__ directly to generate whatever you want. Or use https://github.com/jsonpickle/jsonpickle I guess...

guettli commented 3 years ago

thank you for the quick answer.

It is perfectly fine that python-hunter focuses on creating events, and does not care about dumping them.

Dumping the event to JSON is simple. If I have something worth sharing, I will contact you again.