New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move casting prompt after its validation in _raw_input() #81647
Comments
I think it is more efficient to cast
I tested on 10 millions inputs with above code. Before: After: |
This is a subtle change with the potential to affect more than just performance. Also, in this case, the performance is likely negligible in every actual use-case. This might actually be more correct, though. For example, one would expect passing prompt=None to result in no prompt displayed, rather than "None". |
I don't think that will work. If the user passes a non-string which is falsey, your patch will attempt to write it directly to the stream without converting it to a string. Try Tal Einat:
I wouldn't. That's not how getpass works now, or input. By the way, myungsekyo, that's not the best way to use timeit to time code snippets. You are timing the overhead of the loop, ten million lookups of the name "_raw_input", and most importantly, ten million times that _raw_input halts waiting for input from the user. Surely you didn't sit there hitting Enter over and over again? |
Ah, thanks for the input, Steve. In that case, this should likely not be changed. |
Thanks to your reviews! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: