when it comes to modules with timeit, i've found that passing globals=globals() could be a good alternative to setup parameter, especially when there are many modules to worry about in your timeit. although this would require you to actually import the modules in your python file, i'm sure you would have done that already. but you also would be able to use variables in the global scope edit: it has been 8 minutes in. this is mentioned. i shall now eat my legs, for that would be the only way to correct this mistake
I got ths error when running your code in the globals section of the video: " def list_generate_random(amount: int) -> list[float]: TypeError: 'type' object is not subscriptable "
Unlikely I will bring it to the channel any time in the near future, but if you're more than welcome to learn it from my full Python course on indently.io
Yeah I found that interesting as well. Couldn’t tell you why they did that. Maybe it added far too much complexity to timeit. Or maybe they wanted to make sure that users understood that one returns a list of floats, while the other just returns a float. Those are just my ideas :)
i used timeit's default_timer from timeit import default_timer as timer start = timer() """some statements talking to DB""" print(f"Time Taken: {timer()-start} sec.")
@@Indently no specific reason. I got it from a stackoverflow answer using this since like this only. maybe because default_timer feels natural than perf_counter. good to know I can do this from the time module only. thx.
when it comes to modules with timeit, i've found that passing globals=globals() could be a good alternative to setup parameter, especially when there are many modules to worry about in your timeit. although this would require you to actually import the modules in your python file, i'm sure you would have done that already. but you also would be able to use variables in the global scope
edit: it has been 8 minutes in. this is mentioned. i shall now eat my legs, for that would be the only way to correct this mistake
Pretty useful. Thanks.
great video, thanks
We can also use Samay module to get execution time and visualization of execution of a function.
I got ths error when running your code in the globals section of the video:
" def list_generate_random(amount: int) -> list[float]:
TypeError: 'type' object is not subscriptable "
I got the utility of using typing in function parameters and returns but specifing the type of everything is too much when is obvius
so don't do it that way... no one is forcing you to do anything....
Can you make a video on multi prossesing in python? Need to know how to do it So i can same my self 30min a Day.
Unlikely I will bring it to the channel any time in the near future, but if you're more than welcome to learn it from my full Python course on indently.io
Why is repeat a different function than timeit? They could just make repeat an option in timeit. Damn "typed" programmers.
Yeah I found that interesting as well. Couldn’t tell you why they did that. Maybe it added far too much complexity to timeit. Or maybe they wanted to make sure that users understood that one returns a list of floats, while the other just returns a float. Those are just my ideas :)
i used timeit's default_timer
from timeit import default_timer as timer
start = timer()
"""some statements talking to DB"""
print(f"Time Taken: {timer()-start} sec.")
Why are you doing these crazy gymnastics when default_timer literally just uses perf_counter? Just curious
@@Indently no specific reason. I got it from a stackoverflow answer using this since like this only. maybe because default_timer feels natural than perf_counter.
good to know I can do this from the time module only. thx.
speak english!!!!
Like British English?