Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timeit module
#1
I'm trying to see the runtime of s.intersection(t) that takes two sets s and t and returns a new set with all the elements that occur in both s and t.

So, for example, i want to try running |s| = 1000 and |t| = 1000

I tried

import timeit
for x in range(1000):
    t = timeit.Timer("s.intersection(t)", "s = set(1000)", "t = set(1000)")

t.timeit()
I keep getting errors no matter what variation I try of Timer(). Any ideas?
Reply


Messages In This Thread
Timeit module - by Miraclefruit - Jan-28-2018, 02:00 AM
RE: Timeit module - by egslava - Jan-28-2018, 02:16 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 02:23 AM
RE: Timeit module - by egslava - Jan-28-2018, 02:27 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 02:29 AM
RE: Timeit module - by snippsat - Jan-28-2018, 03:28 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 03:43 AM
RE: Timeit module - by egslava - Jan-28-2018, 03:48 AM
RE: Timeit module - by snippsat - Jan-28-2018, 04:04 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 04:16 AM

Forum Jump:

User Panel Messages

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