mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-26 02:33:21 +08:00
19 lines
486 B
Python
19 lines
486 B
Python
![]() |
import array
|
||
|
import reprlib
|
||
|
|
||
|
|
||
|
class FixedRepr(reprlib.Repr):
|
||
|
"""Only route python array instances to repr_array."""
|
||
|
|
||
|
def repr_array(self, x, maxlevel):
|
||
|
if isinstance(x, array.array):
|
||
|
return super().repr_array(x, maxlevel)
|
||
|
else:
|
||
|
return self.repr_instance(x, maxlevel)
|
||
|
|
||
|
|
||
|
# We need to monkey-patch reprlib so that we can use the debugger without
|
||
|
# renaming the array to something else
|
||
|
fixed_repr = FixedRepr()
|
||
|
reprlib.repr = fixed_repr.repr
|