[Patches] [ python-Patches-1007068 ] baseinteger: abstract superclass for int and long

SourceForge.net noreply at sourceforge.net
Thu Aug 19 08:08:38 CEST 2004


Patches item #1007068, was opened at 2004-08-11 03:20
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1007068&group_id=5470

Category: Core (C code)
Group: Python 2.4
Status: Open
>Resolution: Rejected
Priority: 5
Submitted By: Dmitry Vasiliev (hdima)
Assigned to: Anthony Baxter (anthonybaxter)
Summary: baseinteger: abstract superclass for int and long

Initial Comment:
Quote from PEP-237
(http://www.python.org/peps/pep-0237.html):

"""
A new type, integer, may be introduced that is an
abstract base type of which both the int and long
implementation types are subclassed.  This is useful so
that programs can check integer-ness with a single test:

    if isinstance(i, integer): ...
"""

The patch implement the superclass for int and long
with name 'baseinteger'.

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2004-08-19 02:08

Message:
Logged In: YES 
user_id=6380

I take it back. Few people on python-dev cared about this,
and there's at least one potential abuse (subclassing from
it won't do the right thing). It's also something that will
go away again in 3.0 (where there will be only one integral
type). Let's just by convention write isinstance(x,
(int,long)) when we really need it.

You may ask what about basestring? Its use case is similarly
weak, and I expect it to disappear in 3.0. Let's not repeat
the mistake.

So I'm rejecting this now. Sorry!

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2004-08-13 10:43

Message:
Logged In: YES 
user_id=6380

+1

One suggestion: I'd add some words to the docs to recommend
*not* to use this for one's own integer-ish class. Instead,
subclassing from int or long is recommended, to avoid
confusion (since many built-in operations and extensions
accept only "genuine" integers, i.e. int or long or
subclasses thereof).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1007068&group_id=5470


More information about the Patches mailing list