When you import modules, you can choose whether to import two modules or from, and I wonder what the difference is.
The code itself doesn't change anyway, but I want to know which of the two is more advantageous.(e.g. faster module calls)
Or is it just for shortening the command code?
import time
time.sleep(10)
from time import sleep
sleep(10)
Experiments have shown that module calls do not speed up
I think it's only used to shorten the command code
I think it's the speed difference of import.
From ~ import ~ is a command to import only a specific module portion of the library, and import is a function to just import the entire library.
If you are simply trying to write sleep, there will be little difference in speed whether you import the time library or from sleep. However, when you need to create multiple classes or create another library from one library, importing functions that you don't need can slow you down, so you can import only the parts that are needed for optimization.
865 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
573 PHP ssh2_scp_send fails to send files as intended
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.