英文:
Substituting Python built-in function name to the a new function
问题
我在这个平台上提出了我的第一个问题。在用Python解决算法问题时,我遇到了一个问题,但我不知道如何在Google上找到相关的官方文档。你能帮助我吗?
这是下面的代码。
input = stdin.readline
T = int(input())
因为速度的原因,我将使用stdin.readline()函数替代input()函数。
我知道它可以正常工作,没有语法问题,但我不知道如何找到相关的概念或文档。
英文:
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.
答案1
得分: 1
我相信你想要使用类似这样的stdin.read
函数:
from sys import stdin
print("\n".join(stdin.read().split()))
和
input = stdin.readline
已经将输入函数重命名为stdin.read
,尽管性能差异应该可以忽略不计。
我建议你使用一个不同的解释器,比如pypy3,或者使用cpython来加速你的程序,并改进你程序的其他部分。或者如果你认为你的算法已经处于最优状态,那就切换到另一种编程语言。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论