[Python-Dev] Please comment on PEP 357 -- adding nb_index slot to PyNumberMethods (original) (raw)

Armin Rigo arigo at tunes.org
Fri Feb 17 17:29:32 CET 2006


Hi Travis,

On Tue, Feb 14, 2006 at 08:41:19PM -0700, Travis E. Oliphant wrote:

2) The index special method will have the signature

def index(self): return obj Where obj must be either an int or a long or another object that has the index special method (but not self).

The "anything but not self" rule is not consistent with any other special method's behavior. IMHO we should just do the same as nonzero():

This ensures that there is no infinite loop in C created by a nonzero that returns something that has a further nonzero method.

The rule that the PEP proposes for index (returns anything but not 'self') is not useful, because you can still get infinite loops (you just have to work slightly harder, and even not much). We should just say that index must return an int or a long.

A bientot,

Armin



More information about the Python-Dev mailing list