2

Preface

There is a standard Python implementation known as CPython. But it is not the only one, currently I'm working with alternative implementation named PyPy.

Problem

I have a strange inconsistency in behavior of PyPy & CPython implementations of Python3.5 on Windows 10 x64 with next snippet (thanks to @Gabriel, completed example)

>>> from itertools import repeat
>>> repeat(None, 2**31)

in CPython it gives

repeat(None, 2147483648)

while in PyPy it ends up in error with odd message

Traceback (most recent call last):
  File "<input>", line 1, in <module>
OverflowError: int too large to convert to int

but when I try to execute this snippet in PyPy inside of Docker container

docker run -it pypy:3-6

it works fine, as CPython version.

I know that Windows version is in beta stage, but can anyone explain why it behaves like this and what does this error message say (or what it should say)?

Update

For CPython however next statement

>>> repeat(None, 2**63)

gives

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t

are these errors somehow related?

Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
  • Just a guess, but I'm assuming this is due to a change with integers between 3.5 and 3.6 – jhomr Oct 05 '18 at 17:51
  • I guess windows has some crappy 32 bit build of itertools – wim Oct 05 '18 at 17:51
  • 1
    My [question](https://stackoverflow.com/questions/41705764/numpy-sum-giving-strange-results-on-large-arrays) is possibly related. Default integer type on Windows is 32 bit – roganjosh Oct 05 '18 at 17:51
  • 1
    that's probably because `2148000000 > 2**31` – Gabriel Oct 05 '18 at 17:52
  • @jhomr: nope, it's not, I have *Python3.5.3* for both implementations – Azat Ibrakov Oct 05 '18 at 18:03
  • What distro is your docker container using? According to `http://doc.pypy.org/en/latest/faq.html#on-which-platforms-does-pypy-run` PyPy supports 64 bit Linux and Mac but only 32 bit Windows. – jhomr Oct 05 '18 at 18:13

0 Answers0