Grab co-authorship; added list of things that will/may change; added
alternative implementation.
This commit is contained in:
parent
77a48daeeb
commit
d975139bb9
41
pep-0237.txt
41
pep-0237.txt
|
@ -1,7 +1,7 @@
|
||||||
PEP: 237
|
PEP: 237
|
||||||
Title: Unifying Long Integers and Integers
|
Title: Unifying Long Integers and Integers
|
||||||
Version: $Revision$
|
Version: $Revision$
|
||||||
Author: pep@zadka.site.co.il (Moshe Zadka)
|
Author: pep@zadka.site.co.il (Moshe Zadka), guido@python.org (Guido van Rossum)
|
||||||
Status: Draft
|
Status: Draft
|
||||||
Type: Standards Track
|
Type: Standards Track
|
||||||
Created: 11-Mar-2001
|
Created: 11-Mar-2001
|
||||||
|
@ -18,6 +18,10 @@ Abstract
|
||||||
types from the perspective of both the Python interpreter and the
|
types from the perspective of both the Python interpreter and the
|
||||||
C API.
|
C API.
|
||||||
|
|
||||||
|
Note from second author: this PEP requires more thought about
|
||||||
|
implementation details. I've started to make a list of semantic
|
||||||
|
differences but I doubt it's complete.
|
||||||
|
|
||||||
|
|
||||||
Rationale
|
Rationale
|
||||||
|
|
||||||
|
@ -72,9 +76,39 @@ Overflows
|
||||||
aid, and has no guaranteed semantics.
|
aid, and has no guaranteed semantics.
|
||||||
|
|
||||||
|
|
||||||
|
Semantic Differences
|
||||||
|
|
||||||
|
The following operations have (usually subtly) different semantics
|
||||||
|
for short and for long integers, and one will have to change
|
||||||
|
somehow. This is intended to be an exhaustive list; if you know
|
||||||
|
of anything else that might change, please write the author.
|
||||||
|
|
||||||
|
- Currently, all arithmetic operators on short ints except <<
|
||||||
|
raise OverflowError if the result cannot be represented as a
|
||||||
|
short int. This will change (of course).
|
||||||
|
|
||||||
|
- Currently x<<n can lose bits for short ints. No more.
|
||||||
|
|
||||||
|
- Currently, hex and oct literals for for short ints may specify
|
||||||
|
negative values; for example 0xffffffff == -1 on a 32-bint
|
||||||
|
machine. No more; this will equal 2**32-1.
|
||||||
|
|
||||||
|
- Currently, repr() of a long int returns a string ending in 'L'
|
||||||
|
while repr() of a short int doesn't. The 'L' will be dropped.
|
||||||
|
|
||||||
|
- Currently, an operation with long operands will never return a
|
||||||
|
short int. This may change.
|
||||||
|
|
||||||
|
- Currently, type(x) may reveal the difference between short and
|
||||||
|
long ints. This may or may not change (see Implementation
|
||||||
|
below).
|
||||||
|
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
The PyInt type's slot for a C long will be turned into a
|
There are two alternative implementations to choose from.
|
||||||
|
|
||||||
|
1. The PyInt type's slot for a C long will be turned into a
|
||||||
|
|
||||||
union {
|
union {
|
||||||
long i;
|
long i;
|
||||||
|
@ -89,6 +123,9 @@ Implementation
|
||||||
will check this bit before deciding which types of operations to
|
will check this bit before deciding which types of operations to
|
||||||
use.
|
use.
|
||||||
|
|
||||||
|
2. The existing short and long int types remain, but the short int
|
||||||
|
returns a long int instead of raising OverflowError.
|
||||||
|
|
||||||
|
|
||||||
Jython Issues
|
Jython Issues
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue