Issue 1007068: baseinteger: abstract superclass for int and long (original) (raw)

Created on 2004-08-11 07:20 by hdima, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
baseinteger.patch hdima,2004-08-11 07:20 baseinteger patch
Messages (4)
msg46663 - (view) Author: Dmitry Vasiliev (hdima) Date: 2004-08-11 07:20
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'.
msg46664 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-08-13 14:43
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).
msg46665 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-08-19 06:08
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!
msg46666 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2004-08-19 15:10
Logged In: YES user_id=33168 Assuming Guido wanted this closed too.
History
Date User Action Args
2022-04-11 14:56:06 admin set github: 40741
2004-08-11 07:20:19 hdima create