mlx/python/mlx/_reprlib_fix.py

17 lines
321 B
Python
Raw Normal View History

2023-12-01 03:12:53 +08:00
# Copyright © 2023 Apple Inc.
2023-11-30 02:30:41 +08:00
import array
import reprlib
2024-09-17 04:21:04 +08:00
_old_repr_array = reprlib.Repr.repr_array
2023-11-30 02:30:41 +08:00
2024-09-17 04:21:04 +08:00
def repr_array(self, x, maxlevel):
if isinstance(x, array.array):
return _old_repr_array(self, x, maxlevel)
else:
return self.repr_instance(x, maxlevel)
2023-11-30 02:30:41 +08:00
2024-09-17 04:21:04 +08:00
reprlib.Repr.repr_array = repr_array