Home > Enterprise >  Substituting Python built-in function name to the a new function
Substituting Python built-in function name to the a new function

Time:01-12

I'm leaving my first question on this platform. I got a question while solving algorithm problems with Python, but I don't know how to find related official documents on Google. Can you help me?

This is the code down there.

input = stdin.readline

T = int(input())

Because of the speed, I'm going to replace the input() function with stdin.readline(). I know it works without any grammatical problems, but I don't know how to find relevant concepts or documents.

CodePudding user response:

I believe you want to use the stdin.read function similar to this:

from sys import stdin
print("\n".join(stdin.read().split()))

and the

input = stdin.readline

have already renamed the input function to be the stdin.read

,dough the performance difference should be negligible.

I would suggest you use a different interpreter such as pypy3 or use cpython to speeding your program and
improve the other parts of your program or if you think your algorithm is in the most optimal state possible then just switch to an other programming language.

  • Related