[pypy-issue] [issue1765] __len__ can't return big numbers

Ram Rachum tracker at bugs.pypy.org
Sun May 11 23:08:48 CEST 2014


New submission from Ram Rachum <ram at rachum.com>:

I have just opened the same issue on CPython, and it was closed as a limitation 
of the implementation: http://bugs.python.org/issue21444?
@ok_message=msg%20217957%20created%0Aissue%2021444%20created&@template=item

Maybe Pypy-dev would like to implement this.

I want to use big numbers for an object's length, but currently Pypy doesn't 
support this: 

    Python 2.7.6 (394146e9bb67, May 08 2014, 18:18:57)
    [PyPy 2.3.0 with MSC v.1500 32 bit] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>> class A(object):
    ....     def __len__(self):
    ....         return 10 ** 100
    ....
    >>>> a = A()
    >>>> len(a)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OverflowError: long int too large to convert to int

Same thing happened on Pypy3:

    Python 3.2.3 (d63636b30cc0, Jul 30 2013, 07:02:44)
    [PyPy 2.1.0-beta1 with MSC v.1500 32 bit] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    And now for something completely different: ``it's beautiful: very 
rectangular
    and yellow''
    >>>> class A(object):
    ....     def __len__(self):
    ....         return 10 ** 100
    ....
    >>>> a = A()
    >>>> len(a)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OverflowError: long int too large to convert to int

----------
messages: 6880
nosy: cool-RR, pypy-issue
priority: feature
status: unread
title: __len__ can't return big numbers

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1765>
________________________________________


More information about the pypy-issue mailing list