This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: allow timeit to see your globals()
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, skip.montanaro, tim.peters
Priority: normal Keywords: patch

Created on 2003-04-08 15:44 by skip.montanaro, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
timeit.diff skip.montanaro, 2003-04-08 15:55
Messages (5)
msg43294 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-04-08 15:44
This patch allows the timeit caller to specify the globals() for the
code snippet being timed.
msg43295 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-04-25 19:01
Logged In: YES 
user_id=31435

Reassigned to timeit's author.
msg43296 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-04-25 19:19
Logged In: YES 
user_id=6380

What's the use case?
msg43297 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-04-25 19:33
Logged In: YES 
user_id=44345

The first time I wanted to use timeit, I wanted to define a small function
of a few lines and have that timed.  Since the function was in my global
namespace, not that of timeit, I couldn't time it.  The only other way to get
it timed would be to shove it into builtins.
msg43298 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-04-25 19:41
Logged In: YES 
user_id=6380

You could've copy-pasted it into the setup code. Or you
could've put

  from __main__ import my_function

in the setup code. I think passing in globals is just
another way of doing something you can already do.
History
Date User Action Args
2022-04-10 16:08:03adminsetgithub: 38274
2003-04-08 15:44:38skip.montanarocreate