pajenegod's blog

By pajenegod, history, 4 years ago, In English

I've always liked using Python (PyPy) for solving problems in competitive programming. And most problems are very doable, even in Python. What I've found is that the most difficult problems to solve in Python are those requiring 64 bit integers.

The reason why 64 bit integers are problematic is because CF runs Windows, and PyPy only supports 32 bit on Windows. So whenever a problem involves integers that cannot fit inside of a signed 32 bit int, PyPy switches to big integers (which runs insanely slow, sometimes a factor of 20 times slower).

What I currently have to do to get around big integers

However with the latest PyPy version (version 7.3.4) PyPy has finally switched to 64 bit on Windows! So upgrading PyPy would mean no more problems with big integers. This would make PyPy far more usable and more beginner friendly. So if possible please update PyPy's version on CF to 7.3.4! MikeMirzayanov

Edit: Reading Results of 2020 [list some changes and improvements] blog I realized that I should probably be tagging geranazavr555, kuviman and cannor147 too.

  • Vote: I like it
  • +642
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it +30 Vote: I do not like it

Auto comment: topic has been updated by pajenegod (previous revision, new revision, compare).

»
4 years ago, # |
  Vote: I like it +41 Vote: I do not like it

I got TLE on a problem where n^2 should have passed because of this issue, so I think this would be very helpful.

»
4 years ago, # |
  Vote: I like it +34 Vote: I do not like it

I too, as an python main, really struggled upon this specific matter. Hope this change ships soon so that more people can focus and enjoy the nature of problem-solving with python, not exploring some deprecated features just to make some plain old multiplications to get going.

»
4 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Clever workarounds in 1 and 3.

»
4 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Hey, the community should need to take this blog seriously and make the required changes in PYPY. during the contest, I made logic and coded it but the submission got TLE. I taught my approach was not optimal and started to think of other ways to solve that problem. finally ended not solving it. after the contest realized My idea is the only optimal way to solve it and all the people with python submission got TLE, only a few people who already know the above trick got accepted in PYPY. The tester of the round should have tried python also and they would have figured the TLE problem or they have not tested with python. please Do the need full I believe solving problems and learning should need to be the main goal the programming language we use should not be a barrier to it.

»
4 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Auto comment: topic has been updated by pajenegod (previous revision, new revision, compare).

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It is probably dumb to ask but can anyone tell me how to update PyPy version on CF

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It is not for you to update. You will be able to use the new version when Codeforces updates it on their site.

»
4 years ago, # |
Rev. 2   Vote: I like it +41 Vote: I do not like it

I will just bump this thread as it seems extremely relevant to today's contest

»
4 years ago, # |
  Vote: I like it +9 Vote: I do not like it

bump. relevant to C and D of Codeforces Round 727 (Div. 2)

»
4 years ago, # |
  Vote: I like it +12 Vote: I do not like it

I am just bumping as no action has been taken
and today many suffered due to this

I know some people will say just switch to C++ but is that really a solution?

»
4 years ago, # |
  Vote: I like it +35 Vote: I do not like it

Pypy authors stopped releasing 32-bit version and its slightly tricky to support 64-bit version in our current setup.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +88 Vote: I do not like it

    OP isn't just asking for an upgrade of PyPy's version, he specifically wants the 64-bit version. Even if the pypy author had continued supporting 32 bit, upgrading that wouldn't solve our issues!

    The analogy is something like 64 bit C++ gave them the __int128 type. 64 bit pypy will give us ... long long. Like we will finally be able to multiply two int and take a mod without TLEing. That's the pathetic state of python on CF right now. (And it really is a CF specific problem because who else is still stuck using 32-bit in 2021)

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +144 Vote: I do not like it

    Hi geranazavr555, thanks for reply!

    The reason why I wrote this blog was to request Codeforces to upgrade to 64 bit PyPy, and to talk about the benifits of 64 bit vs 32 bit. There are some really huge benifits gained from switiching to 64 bit PyPy.

    Pypy authors stopped releasing 32-bit version

    This doesn't really matter, at least not as far as this blog is concerned. This blog is about upgrading to 64 bit PyPy, and not about updating the current 32 bit version.

    its slightly tricky to support 64-bit version in our current setup.

    That is unfortunate to hear. But at least know that in my opinion (and in many other people's opinion) 64 bit PyPy is by far the most crucial feature missing on Codeforces.

  • »
    »
    3 years ago, # ^ |
    Rev. 3   Vote: I like it +8 Vote: I do not like it

    Also why does the float method work faster until 2 raised to 52 only?

    Speed comparison

    Integers > floats > big integers

    Am I correct?

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Python float's are equivalent to C++ double's, they can only store 52 bits of precision exactly, and for integers larger than that, they have to use base-2 scientific notation (for more info about this, see the IEEE 754 standard and check how floats are encoded here)

      • »
        »
        »
        »
        3 years ago, # ^ |
        Rev. 2   Vote: I like it +3 Vote: I do not like it

        Thanks man. Now I know why floats won't work fast beyond 2**52.

        Is there anything like long double equivalent in python which has more than 52 bits precision.

        Maybe this library can be helpful from decimal import Decimal

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it +3 Vote: I do not like it
          1. There's no long double in Python
          2. Yes, there's an arbitrary-precision decimal library in python: decimal.Decimal. I may as well say here that there's also fractions.Fraction for arbitrarily large rational numbers.
  • »
    »
    3 years ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    So when is the pypy64 bit getting updated?

    It has been 5 month since the post.

    What is the problem in the current setup?

  • »
    »
    3 years ago, # ^ |
    Rev. 3   Vote: I like it +3 Vote: I do not like it

    Waiting for the pypy64 bit version. Once I saw this version's submission here

    geranazavr555 please update pypy64 bit as soon as possible.

    Also can the better diagnosis be available in pypy/python submissions like runtime error on line 5 just like it shows in c++ on Codeforces submission. This would be a great help in debugging.

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      It means that the work is in progress. We are working on it. It will be released soon.