Python Forum
Alternative to dynamic variable names
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alternative to dynamic variable names
#11
Why your results are different from my results? What I am doing wrong?
Reply
#12
Use https://docs.python.org/3/library/timeit.html instead of time
Reply
#13
Several things are wrong
  • The print() statement is very slow and its execution time varies. Don't include it in the test.
  • Here you want to compare the difference between vars()['foo'] and my['foo']. Don't include anything else in the test
  • Use the timeit module, which is much more precise because it runs the statements 1,000,000 times by default and uses a good timer.
Reply
#14
Thank you all!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Twilio alternative jmair 3 3,885 Feb-08-2024, 01:55 PM
Last Post: Sharmi
  dynamic variable name declaration in OOP style project problem jacksfrustration 3 768 Oct-22-2023, 10:05 PM
Last Post: deanhystad
  Pillow alternative? kucingkembar 4 864 Jul-27-2023, 10:50 AM
Last Post: Larz60+
  Alternative for Cairosvg? Maryan 0 2,446 Oct-26-2020, 01:27 PM
Last Post: Maryan
  Use dynamic variable from parallel running python script Sicksym 0 1,840 May-15-2020, 02:52 PM
Last Post: Sicksym
  Can I use iteration to create variable names? Mark17 8 6,811 Oct-17-2019, 06:05 AM
Last Post: perfringo
  another alternative to np.interp evelynow 1 2,909 Aug-22-2019, 03:32 PM
Last Post: Larz60+
  Multithreading alternative MartinV279 1 2,771 Aug-01-2019, 11:41 PM
Last Post: scidam
  Array alternative oldcity 3 3,467 Oct-01-2018, 10:03 PM
Last Post: ichabod801
  How do I create a Dynamic Variable? Nwb 1 2,747 Jun-10-2018, 11:50 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020