Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8654
| Subject | Re: subtle error slows code by 10x (builtin sum()) - replace builtin sum without using import? |
|---|---|
| From | Albert Hopkins <marduk@letterboxes.org> |
| Date | 2011-07-01 22:54 -0400 |
| References | <f6dbf631-73a9-485f-8ada-bc7376ac686b@h25g2000prf.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.552.1309575260.1164.python-list@python.org> (permalink) |
On Friday, July 1 at 19:17 (-0700), bdb112 said: > Question: > Can I replace the builtin sum function globally for test purposes so > that my large set of codes uses the replacement? > > The replacement would simply issue warnings.warn() if it detected an > ndarray argument, then call the original sum > I could then find the offending code and use the appropriate import to > get numpy.sum You shouldn't do this, but you could use the __builtins__ module e.g. >>> __builtins__.sum = numpy.sum # bad
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
subtle error slows code by 10x (builtin sum()) - replace builtin sum without using import? bdb112 <boyd.blackwell@gmail.com> - 2011-07-01 19:17 -0700 Re: subtle error slows code by 10x (builtin sum()) - replace builtin sum without using import? Albert Hopkins <marduk@letterboxes.org> - 2011-07-01 22:54 -0400 Re: subtle error slows code by 10x (builtin sum()) - replace builtin sum without using import? Chris Torek <nospam@torek.net> - 2011-07-02 03:13 +0000
csiph-web