Why long integers

J

Joe Green

I have been wondering why we have Long integers as a seperate type:

import sys
a=sys.maxint+1 # gives 2147483648L <- coerced to Long
a=2147483648 # gives 2147483648L <- coerced to Long

so the first question is: what is the point of the L in a=2147483648L ?
and:

a-=a #gives 0L

what is the advantage (or point of) it remaining Long ?

What I am tryinfg to say is, why is there not just an Integer type, which is
normally 2 bytes, but expands AND contracts as necessary ?
(Part of the explanation will be historical, but ignoring that)
 
G

Gerrit Holl

Tim said:
[Joe Green]
I have been wondering why we have Long integers as a seperate type:
...

Please see

http://www.python.org/peps/pep-0237.html

Why is it PEP 237 is not implemented using __future__?
There are several incompatible changes: x<<n, 0xffffffff, etc.
I am not a computer scientist so I do not understand why this
behaved like it did in the past (nor do I really care), but being
able to user a from __future__ import foo statement seems applicable
here. Why hasn't it been applied here?

regards,
Gerrit Holl.

--
280. If while in a foreign country a man buy a male or female slave
belonging to another of his own country; if when he return home the owner
of the male or female slave recognize it: if the male or female slave be a
native of the country, he shall give them back without any money.
-- 1780 BC, Hammurabi, Code of Law
 
G

Greg Ewing (using news.cis.dfn.de)

Gerrit said:
Why is it PEP 237 is not implemented using __future__?

Probably because they're not the kind of changes that
you can choose to turn on or off on a per-module
basis!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top