Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85535
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Subject | Re: line_profiler: what am I doing wrong? |
| Date | 2015-02-11 15:42 +0000 |
| References | <mailman.18635.1423613207.18130.python-list@python.org> <54daa1d6$0$12979$c3e8da3$5496439d@news.astraweb.com> <mailman.18639.1423615521.18130.python-list@python.org> <54daada4$0$12998$c3e8da3$5496439d@news.astraweb.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18659.1423669372.18130.python-list@python.org> (permalink) |
On 2015-02-11 01:17, Steven D'Aprano wrote: > Neal Becker wrote: > > >> To quote from https://pypi.python.org/pypi/line_profiler/ >> >> $ kernprof -l script_to_profile.py >> kernprof will create an instance of LineProfiler and insert it into the >> __builtins__ namespace with the name profile. > > Ewww!!!! What a Ruby-esque interface, that makes me sad :-( <shrug> This is not a production library. It's a development tool designed to help developers shorten the cycle time for investigating these kinds of issues. Well, *a* developer; i.e. me. If it helps anyone else, yahtzee! > And what if you > have your own profile global name? Then you can pull it out from __builtin__ with a different name and use that other name. > And *wrong* too. `__builtins__` is a private CPython implementation detail. > The way to monkey-patch the built-ins in Python 2 is to inject the object > into `__builtin__` (no s), or `builtins` in Python 3. And indeed that is how it is implemented. Referring to that namespace as the "`__builtins__` namespace" isn't *wrong*. It may mislead you into thinking I've implemented it one particular way, if you are desperate to find a nit to pick. > Seeing as > line_profiler is written in C, perhaps the author (Robert Kern) doesn't > care about supporting Jython or IronPython, but there may be Python > implementations (PyPy perhaps?) which can run C code but don't have > __builtins__. Indeed, I do not care about any of them. PyPy does not implement CPython's tracing API: https://bitbucket.org/pypy/pypy/src/2b2163d65ee437646194a1ceb2a3153db24c5f7e/pypy/module/cpyext/stubs.py?at=default#cl-1286 -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-10 19:06 -0500
Re: line_profiler: what am I doing wrong? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-11 11:27 +1100
Re: line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-10 19:45 -0500
Re: line_profiler: what am I doing wrong? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-11 12:17 +1100
Re: line_profiler: what am I doing wrong? Robert Kern <robert.kern@gmail.com> - 2015-02-11 15:42 +0000
Re: line_profiler: what am I doing wrong? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-12 10:02 +1100
Re: line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-13 08:33 -0500
csiph-web