Ben Roberts added the comment:
Thanks Antoine. Cheers :-)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2527
___
___
Python-bugs-list mailing
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
--
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
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
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
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
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
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
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
___
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
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
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
___
___
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
___
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
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
Changes by Georg Brandl ge...@python.org:
--
assignee: rhettinger - pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2527
___
___
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
___
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
___
Changes by Raymond Hettinger rhettin...@users.sourceforge.net:
--
assignee: - rhettinger
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2527
___
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 *')
Changes by Steven D'Aprano st...@pearwood.info:
--
nosy: +stevenjd
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2527
___
___
Python-bugs-list
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
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
...
#
Changes by Benjamin Peterson [EMAIL PROTECTED]:
--
nosy: +georg.brandl
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2527
__
___
Python-bugs-list mailing list
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]
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.
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
__
27 matches
Mail list logo