[issue2527] Pass a namespace to timeit

2014-08-23 Thread Ben Roberts
Ben Roberts added the comment: Thanks Antoine. Cheers :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___ ___ Python-bugs-list mailing

[issue2527] Pass a namespace to timeit

2014-08-22 Thread Roundup Robot
Roundup Robot added the comment: New changeset e0f681f4ade3 by Antoine Pitrou in branch 'default': Issue #2527: Add a *globals* argument to timeit functions, in order to override the globals namespace in which the timed code is executed. http://hg.python.org/cpython/rev/e0f681f4ade3 --

[issue2527] Pass a namespace to timeit

2014-08-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: Thank you, Ben! Your patch is now pushed to the default branch. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527

[issue2527] Pass a namespace to timeit

2014-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ben, thanks for the patch. Have you signed a contributor's agreement? You can find it at https://www.python.org/psf/contrib/contrib-form/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527

[issue2527] Pass a namespace to timeit

2014-08-21 Thread Ben Roberts
Ben Roberts added the comment: I did sign one right after I submitted the patch. Takes a few days for the asterisks to propagate I guess :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527

[issue2527] Pass a namespace to timeit

2014-08-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ah, good. The patch looks fine to me, except that you should add versionchanged tags in the documentation for the added parameter. -- stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org

[issue2527] Pass a namespace to timeit

2014-08-21 Thread Ben Roberts
Ben Roberts added the comment: Ah yes. New patch improves the docs. -- Added file: http://bugs.python.org/file36432/timeit_global_arg_v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527

[issue2527] Pass a namespace to timeit

2014-08-18 Thread Ben Roberts
Ben Roberts added the comment: Attached is a patch that adds a 'global' kwarg to the Timeit constructor, which does pretty much what it says on the tin: specifies a global namespace that exec() will use. I originally had a 'locals' arg as well (to mirror the signature of eval/exec), but

[issue2527] Pass a namespace to timeit

2014-08-18 Thread Ben Roberts
Ben Roberts added the comment: Correction, the name of the argument is 'globals', not 'global'. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___

[issue2527] Pass a namespace to timeit

2014-08-17 Thread Ben Roberts
Changes by Ben Roberts bjr.robe...@gmail.com: -- nosy: +roippi ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___ ___ Python-bugs-list mailing

[issue2527] Pass a namespace to timeit

2014-08-06 Thread Antoine Pitrou
Antoine Pitrou added the comment: Would still be nice to have something like this. The timeit module API is still crippled, especially now that from __main__ import * doesn't work in a function anymore. -- stage: patch review - needs patch versions: +Python 3.5 -Python 3.3

[issue2527] Pass a namespace to timeit

2011-11-19 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___ ___

[issue2527] Pass a namespace to timeit

2010-08-26 Thread Mark Lawrence
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- stage: - patch review versions: +Python 3.2 -Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___

[issue2527] Pass a namespace to timeit

2009-04-03 Thread Stefan van der Walt
Changes by Stefan van der Walt ste...@sun.ac.za: -- nosy: +stefanv ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___ ___ Python-bugs-list

[issue2527] Pass a namespace to timeit

2009-02-06 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: I'm sorry, this should have been another issue. Reassigning to you. -- assignee: pitrou - rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527

[issue2527] Pass a namespace to timeit

2009-02-05 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- assignee: rhettinger - pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___ ___

[issue2527] Pass a namespace to timeit

2009-02-05 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Georg, why did you reassign this? ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___

[issue2527] Pass a namespace to timeit

2009-02-04 Thread Raymond Hettinger
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- priority: - normal versions: +Python 2.7, Python 3.1 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___

[issue2527] Pass a namespace to timeit

2009-01-26 Thread Raymond Hettinger
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- assignee: - rhettinger nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___

[issue2527] Pass a namespace to timeit

2009-01-24 Thread David W. Lambert
David W. Lambert lamber...@corning.com added the comment: This note is simply a reminder that Antoine's 'from __main__ import *' solution fails in python3. Also, resolution of this issue probably could incorporate Issue1397474. import timeit timeit.timeit('None','from __main__ import *')

[issue2527] Pass a namespace to timeit

2009-01-23 Thread Steven D'Aprano
Changes by Steven D'Aprano st...@pearwood.info: -- nosy: +stevenjd ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2527 ___ ___ Python-bugs-list

[issue2527] Pass a namespace to timeit

2008-04-02 Thread Peter Otten
Peter Otten [EMAIL PROTECTED] added the comment: Alexander, I'm fine with a more specific argument name. ns was what the Timer already used internally. Antoine, from __main__ import name1, ..., nameN works fine on the command line, but inside a function you'd have to declare the names you

[issue2527] Pass a namespace to timeit

2008-04-01 Thread Peter Otten
New submission from Peter Otten [EMAIL PROTECTED]: I'd like to suggest a different approach than the one taken in rev. 54348 to improve timeit's scripting interface: allow passing it a namespace. Reasons: - It has smaller overhead for functions that take an argument: def f(a): pass ... #

[issue2527] Pass a namespace to timeit

2008-04-01 Thread Benjamin Peterson
Changes by Benjamin Peterson [EMAIL PROTECTED]: -- nosy: +georg.brandl __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2527 __ ___ Python-bugs-list mailing list

[issue2527] Pass a namespace to timeit

2008-04-01 Thread Alexander Belopolsky
Alexander Belopolsky [EMAIL PROTECTED] added the comment: A more general approach would be to add both 'locals' and 'globals' to be used by exec. At least, I would change 'ns' to 'locals'. -- nosy: +belopolsky __ Tracker [EMAIL PROTECTED]

[issue2527] Pass a namespace to timeit

2008-04-01 Thread Alexander Belopolsky
Alexander Belopolsky [EMAIL PROTECTED] added the comment: On the second thought, I actually wanted Timer to mimic eval without realizing that eval uses positional rather than keywords arguments. 'locals' is obviously a bad choice for the keyword parameter because it masks locals() builtin.

[issue2527] Pass a namespace to timeit

2008-04-01 Thread Antoine Pitrou
Antoine Pitrou [EMAIL PROTECTED] added the comment: Generally, when I use timeit from the interpreter prompt, I use from __main__ import * as the setup code string. Then I can use all currently defined global symbols directly :) -- nosy: +pitrou __