Nick Coghlan added the comment:

The problem I see is that we have conflicting requirements for the default 
behaviour:

- if we modify dis() instead of adding a new function, then the default 
behaviour needs to be non-recursive for backwards compatibility reasons
- if we allow the depth to be configurable, then we'd like the default 
behaviour to be to show everything

One potential resolution to that would be to define this as a new function, 
`distree`, rather than modifying `dis` and `disassemble` to natively support 
recursion. Then the new function could accept a `depth` argument (addressing my 
concerns), but have `depth=None` as the default (addressing your concerns).

If we wanted to allow even more control than that, then I think os.walk 
provides a useful precedent, where we'd add a new `dis.walk` helper that just 
looked at `co_consts` to find nested code objects without doing any of the 
other disassembly work.

The dis.walk() helper would produce an iterable of (depth, code, nested) 
3-tuples, where:

- the first item is the current depth in the compile tree
- the second is the code object itself
- the third is a list of nested code objects

Similar to os.walk(), editing the list of nested objects in place would let you 
control whether or not any further recursion took place.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11822>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to