
01.04.20 21:45, Ilya Kamenshchikov пише:
I needed reversed(enumerate(x: list)) in my code, and have discovered that it wound't work. This is disappointing because operation is well defined. It is also well defined for str type, range, and - in principle, but not yet in practice - on dictionary iterators - keys(), values(), items() as dictionaries are ordered now. It would also be well defined on any user type implementing __iter__, __len__, __reversed__ - think numpy arrays, some pandas dataframes, tensors.
I am not sure that it is well defined. It was not clear to me how you define it until I looked at your reference implementation, but your implementation is not compatible with enumerate(). For example it fails test for next(enumerate('a')).
That's plenty of usecases, therefore I guess it would be quite useful to avoid hacky / inefficient solutions like described here: https://code.activestate.com/lists/python-list/706205/.
Could you please provide evidence that this feature would be quite useful? How much usecases can you find in the stdlib?