On Tue, 27 Aug 2019 10:51:52 +0100 Paul Moore firstname.lastname@example.org wrote:
For example, the numpy case might be covered completely by the JSON module just adding supporting for types that provide an __index__ method. So rather than needing a new protocol, an existing one might be perfectly adequate. (Although I've not looked into this in any great detail, so it's entirely likely I've missed something critical - my point is mainly that with a proper use case, we can discuss solutions in the context of a real requirement).
I suspect that __index__ might work for integer-like objects. But then you have to deal with other objects such as numpy.float32, numpy.bool_, etc.