Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48671
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: collecting variable assignments through settrace |
| Date | 2013-06-18 17:47 -0400 |
| References | <0fd5f976-d22c-497d-b829-54ec881c3b6f@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3560.1371592076.3114.python-list@python.org> (permalink) |
On 6/18/2013 2:38 PM, skunkwerk wrote: > Hi, I'm writing a custom profiler that uses sys.settrace. I was > wondering if there was any way of tracing the assignments of > variables inside a function as its executed, without looking at > locals() at every single line and comparing them to see if anything > has changed. The stdlib has an obscure module bdb (basic debugger) that is used in both pdb (python debugger) and idlelib.Debugger. The latter can display global and local variable names. I do not know if it does anything other than rereading globals() and locals(). It only works with a file loaded in the editor, so it potentially could read source lines to looks for name binding statements (=, def, class, import) and determine the names just bound. On the other hand, re-reading is probably fast enough for human interaction. My impression from another issue is that traceing causes the locals dict to be updated with each line, so you do not actually have to have to call locals() with each line. However, that would mean you have to make copies to compare. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
collecting variable assignments through settrace skunkwerk <skunkwerk@gmail.com> - 2013-06-18 11:38 -0700 Re: collecting variable assignments through settrace Terry Reedy <tjreedy@udel.edu> - 2013-06-18 17:47 -0400
csiph-web