Nick Coghlan <ncoghlan <at> gmail.com> writes:
> 
>On Wed, Jul 14, 2010 at 11:50 PM, Petre Galan <Petre.Galan <at> gmail.com
wrote:
>> No. The right interface is PyNumber_Long. The purpose of the PyNumber_Index
>> (and nb_index slot) is as index in slicing.
> 
> Allowing other objects to say "I'm a real integer, treat me as one" is
> exactly what the nb_index slot is for (see PEP 357). The use as an
> index in slicing was just the primary initial use case and the one
> that was chosen as the name for the new slot because nb_int was
> already taken for the lossy transformation. Indexing is not (and never
> has been) intended to be the only use case.
> 

PyNumber_Long is the right interface as it's the right way to do it.
PyNumber_Index allows me to compute a value as index in slicing, value that
may be different that the integer behaviour of object. PyNumber_Index is 
serving 
it's purpose as index in slicing, beyond that it's getting abused.
As for related discussions, float should not implement nb_int slot but be
resolved in int's constructor.

Petre

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to