Блог пользователя kebab_enjoyer

Автор kebab_enjoyer, история, 4 года назад, По-английски

Python is overrated

  • Проголосовать: нравится
  • +20
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

It's an easy alternative when $$$A[i] \gt 10^{19}$$$

  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится +14 Проголосовать: не нравится

    __int128, java bigInteger

  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    And that is never, except when numbers have like 100000 digits and need to be read as string.

    • »
      »
      »
      4 года назад, скрыть # ^ |
      ← Rev. 2  
      Проголосовать: нравится +5 Проголосовать: не нравится

      There was one problem where numbers had size $$$4\cdot 10^{36}$$$ (see 1656H - Одинаковые НОК подмножеств), but I don't think the time limit is very Python-friendly either case, and C++ already has __int128; though one thing to note is that you still have to read input as a string and then convert it to a 128-bit int; output had similar concerns.

      By the way, I'm pretty sure that you can't read a 100000-digit integer as a Python int because I don't know of a way to convert a number of length $$$n$$$ to binary in faster than $$$O(n^2)$$$ time.

      • »
        »
        »
        »
        4 года назад, скрыть # ^ |
         
        Проголосовать: нравится +14 Проголосовать: не нравится

        I'm pretty sure that you can't read a 100000-digit integer as a Python int

        Sure you can read 100000-digit integer in python (161330597).

        I think there is something smarter than plain $$$O(n^2)$$$ algorithm ($$$2^{32}$$$ base for digits already should give some speed-up, and maybe you can do some cool optimizations from fact that for parsing you need multipliing only by ten).

        • »
          »
          »
          »
          »
          4 года назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится

          Wow, thanks for telling me!

          However, even given the simplicity of the code, it took the code over 1 second to run; I won't count on the other operations to be anywhere near efficient, because of all the binary conversions.

          • »
            »
            »
            »
            »
            »
            4 года назад, скрыть # ^ |
            ← Rev. 2  
            Проголосовать: нравится +6 Проголосовать: не нравится

            oh, also, in addition to my explanation below, let me note that this amount of runtime is likely not entirely an issue of computing numbers! there were $$$100$$$ lines of input, $$$100 000 + 6 = 100 006$$$ bytes each, which comes to a maximum input size of a whopping $$$10 000 603$$$-byte ($$$10 MB$$$!) input. considering that he did not use Fast IO, I think about half the runtime went to processing the input. see my submission (161178040) for a solution that uses PyPy 3 and Fast IO.

      • »
        »
        »
        »
        4 года назад, скрыть # ^ |
         
        Проголосовать: нравится +6 Проголосовать: не нравится

        reading a 100000-digit integer, isn't a very big issue by itself in Python, noting that Python integers are essentially big arrays of 64-bit integers. neither is addition or subtraction a big issue. however, big integer multiplication can (and usually do) be a pain in the arse for Python! Python uses the Karatsuba algorithm to multiply big integers, and this algorithm has a $$$O(n^{log_2 3})$$$ time complexity, which can still escalate quite quickly, though faster than an $$$O(n^2)$$$ time complexity multiplication. (using the Decimal type is a possible circumvention to this time complexity, as it is known to be using a Number Theoretic Transform-based implementation for very large numbers). so the point is, while big integer support is a very convenient feature of Python, we at least need to know how fast (or SLOW in some cases!) it works before we use it.

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can't agree more

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Yo!

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Which language do u prefer to train ML models?

»
4 года назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

»
4 года назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

I think it's not wise to say some languages are good/bad without a specific field.

Just like you won't use python for CP, and won't use C/C++ for Web application(well, I know CGI) and deep learning(still, I know Caffe).

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

++++++++++ [>+>+++>+++++++> ++++++++++<<<<-] >>>----.>+++++++ +++++++.------ -----------.++++++++ .+++++.--------. +++++++++++++++.--- ---------------.+++++ +++.<<++.>>--.++ ++++++++.<<.>>++.- ------.------ ----.+.++++ +++++++++..-- ------------- --.++++++++++++++++ +++.----------- ----.-.<<++++ ++++++++++.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -18 Проголосовать: не нравится

Python is terrible,its high precison calculations make the contest unfair.Hope Codeforces can forbidden python in contests.