-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional breakpoints, object attribute mutation detection and hunter #57
Comments
At the very least this is a good cookbook example (https://github.com/ionelmc/python-hunter/blob/master/docs/cookbook.rst). For having something for this builtin I think it should be easy to use from environment. So it needs some import helpers at least. Eg, this should work: from pkg.mod import inst
with hunter.trace(hunter.Watch(inst, 'attr')):
... Also there's the question of there to put this, it's not usable as an action (eg: |
I used it as a predicate. The action in my case (debugging SQLAlchemy intricacies) is either code printer or debugger. The predicate though prints stuff on its own, which is odd. To be usable via |
For sure passing it the object would be more flexible, I'm only asking that it should be usable with a string target (for ease of use from env, with simpler/limited targets of course). So it would need to inherit BaseAction for having output consistent with the other actions. Note that predicates come in 2 implementations (cython/pure). You interested in making a PR for this? (I can do the cython implementation if it's too much) |
I'm interested. |
Another thing, I just noticed you mentioned "conditional breakpoints". So for However that makes it unusable if you only want it to print the value when it has changed. In other words it would work as an event filter, people might want to see what code runs in addition to watching the attribute. The situation could be solved by two ways I think:
Also there's some overlap with VarsPrinter - not really a fan of overlapping functionality - I would like to have things orthogonal. Lemme think a bit about this ... |
So I put these examples in two colums:
Your The actual changes I'm proposing:
Now I realize this is way more than you bargained for, and may be overkill for your really simple use case. And it's less efficient than your simple MutationWatcher. The reasoning is that it should be more general so users don't have to copy-paste the class and change some stuff just to support watching the length of a list or looking up an item. I would also like to discuss some alternatives. Eg: a proposal for a plugin system so you can What do you think? |
@saaj So I've been thinking a bit more about this, and while I don't like the overlap with VarsPrinter now I think your initial proposal is way more simpler, and better than the ideas I thrown around. You still interested in adding a PR with this API?
|
In the sense of this StackOverflow answer do you think the following predicate object is worth inclusion into the library:
If so, does it need any improvements (apart from a docstring)? Better name?
The text was updated successfully, but these errors were encountered: