On Tue, Oct 2, 2012 at 12:55 PM, Katya Stolpovskaya
<[email protected]> wrote:
>
> I have this error:
>
>>>> from sys import *
>>>> maxint
> Traceback (most recent call last):
> File "<pyshell#4>", line 1, in <module>
> maxint
> NameError: name 'maxint' is not defined
>
>
> What does it mean and how to deal with it?

The "int" type in Python 3 is actually a "long", so there is no maxint.

The machine limit that's still relevant in CPython is sys.maxsize
(it's also in Python 2), which should be the maximum value of an
ssize_t (signed size_t) on your platform. For example, this limits the
maximum length of a list. It has to be signed because negative values
are used in some cases to indicate errors. For example, list.sort()
sets the "allocated" size to -1 in order to detect if the list has
been mutated during the sort:

http://hg.python.org/cpython/file/bd8afb90ebf2/Objects/listobject.c#l1932
http://hg.python.org/cpython/file/bd8afb90ebf2/Objects/listobject.c#l2042

Further reading:

Using ssize_t as the index type
http://www.python.org/dev/peps/pep-0353

http://en.wikipedia.org/wiki/C_data_types#Size_and_pointer_difference_types
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to