[Python-Dev] Semantics of __int__(), __index__()

Nick Coghlan ncoghlan at gmail.com
Thu Apr 4 07:37:27 CEST 2013


On 4 Apr 2013 14:58, "Eric Snow" <ericsnowcurrently at gmail.com> wrote:
>
> On Wed, Apr 3, 2013 at 6:47 AM, Hrvoje Niksic <hrvoje.niksic at avl.com>
wrote:
> > It seems like a good feature that an __int__ implementation can choose
to
> > return an int subclass with additional (and optional) information. After
> > all, int subclass instances should be usable everywhere where ints are,
> > including in C code.
>
> Unless you want to try to use the concrete C-API in CPython.  In my
> experience the concrete API is not very subclass friendly.

Using it with subclasses is an outright bug (except as part of a subclass
implementation).

Cheers,
Nick.

>
> -eric
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130404/a1347fd3/attachment.html>


More information about the Python-Dev mailing list