I really like the new jitclass decorator. Not knowing how things work under the hood, it seems like it should be easy-ish to implement `__repr__` and `__str__` methods. For example, say I create some object `Pair`, which just holds a pair of floats. When I'm playing in ipython, I'd like to be able to print the Pair object, and see those two floats. Is this a reasonable possibility?
--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/343ca76e-0305-4893-9d3e-82d3ff6c6bb6%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
ip = get_ipython()
text_formatter=ip.display_formatter.formatters['text/plain']
def _print_jitted_object(arg, p, cycle):
"""Pretty print a jitclass instance"""
p.text("{0}({1}, {2}, {3}, {4})".format(type(arg).__name__, arg.w, arg.x, arg.y, arg.z))
text_formatter.for_type('numba.jitclass.boxing.MyClass', _print_jitted_object);