You pretty much changed the whole comment? Originally you said that an import is almost as fast as property lookup. Dictionaries are stored in memory and modules are stored in the hard drive so importing is not going to be even close as efficient.
Original comment:
fun fact: a import in python is about as efficient as accessing a dictionary with a key (since imports are cached)
still bad practice, but not as awfully inefficient as people tend to assume
If you have already imported something into your program, it's going to be stored in memory, and is thus almost the same as working with dictionaries .
My point was about the initial import not being as fast as looking up a key in a dictionary since you worded it that way. If you said that any subsequent imports are almost as fast as property lookups I'd have no problem with your statement and I'd totally agree.
189
u/ForArms Feb 08 '22
I just don’t know why you would do this, if you can’t measure ping just don’t bother adding a ping method
114
u/K1ngjulien_ Feb 08 '22
just respond with "Pong!" and let the user time it themselves 😉
103
u/mikeywayup Feb 08 '22
I bet they added this to get tests to pass
42
u/seeroflights Feb 08 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
39
u/OnderGok Feb 08 '22
Discord.py literally has a built-in latency method lmao
12
u/Espiring Feb 08 '22
Couldn’t you just use timeit to time the function?
8
u/IvarRagnarssson Feb 08 '22
The worst part is the full import within the function. Like Id get it if it were just the one function, but dont bring the whole library
5
u/SnakeFang12 Feb 08 '22
Respond with a dummy message, then edit it to contain the difference in the command and response messages' timestamps
1
u/arichan97 Aug 07 '22
:( why
1
u/BigPryncypalek Feb 09 '22
AAAAAAAAAAAA
1
u/IceyBecca May 08 '22
Reminds me of a friend who wanted to add a fake prolonged loading screen to their game because “it looks better”
0
u/[deleted] Feb 08 '22
[deleted] — view deleted comment