Cyberbrain
Cyberbrain copied to clipboard
Improve object inspection
- [ ] Show absolute line number
- [ ] Show class name for instances
- [ ] Diffrenciate between tuple, list, set (needs to record the original type)
- [ ] Deal with
'{"py/type": "test_cellvar.test_closure.<locals>.Foo"}'
, which represents a Python class. - [ ] Numpy objects
- [ ] Pandas objects
- [x] Show string with quotes
- [x] Fix:
re.Match
object is null in Js. ( As it turns out, jsonpickle only serializes an object's__dict__
. Are.Match
object has no__dict__
, only attributes defined by descriptors, so was serialized tonull
. ) - [x] Pass truncated
repr
to FE to use as the tooltip text. - [x] Repr truncated on Linux (https://github.com/alexmojaki/cheap_repr/issues/13, https://github.com/alexmojaki/cheap_repr/issues/15)
Conext and Solutions
Right now we use
jsonpickle.encode(python_object, unpicklable=False)
to convert a Python object to JSON. Many information is lost in the conversion. If we use unpicklable=False
, theoretically it's lossless, but we need to handle the extra information (like methods, scopes, etc).
See:
- https://stackoverflow.com/q/2398078/2142577
- https://jsonpickle.readthedocs.io/en/latest/api.html#jsonpickle-high-level-api
Fall back to repr is not a bad choice.
On the Js side, we could use eval
to generate a more user-friendly output. So instead of a plain Js object, we could attach class information by
We can also hide the __proto__
attribute when logging:
https://stackoverflow.com/questions/11818091/hiding-the-proto-property-in-chromes-console