[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation (original) (raw)
Travis E. Oliphant oliphant.travis at ieee.org
Fri Feb 10 02:35:43 CET 2006
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thomas Wouters wrote:
On Thu, Feb 09, 2006 at 02:32:47PM -0800, Brett Cannon wrote:
Looks good to me. Only change I might make is mention why int doesn't work sooner (such as in the rationale). Otherwise +1 from me. I have a slight reservation about the name. On the one hand it's clear the canonical use will be for indexing sequences, and index doesn't look enough like int to get people confused on the difference. On the other hand, there are other places (in C) that want an actual int, and they could use index too. Even more so if a PyArgParse* grew a format for 'the index-value for this object' ;)
There are other places in Python that check specifically for int objects and long integer objects and fail with anything else. Perhaps all of these should aslo call the index slot.
But, then it should be renamed to i.e. "true_int". One such place is in abstract.c sequence_repeat function.
The patch I submitted, perhaps aggressivele, changed that function to call the nb_index slot as well instead of raising an error.
Perhaps the slot should be called nb_true_int?
-Travis
On the other one hand, I can't think of a good name... but on the other other hand, it would be awkward to have to support an old name just because the real use wasn't envisioned yet.
One-time-machine-for-the-shortsighted-quadrumanus-please-ly y'r,s
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]