4 ms·
> version is used to track versions of macros, so that generated bytecodes can be correctly cached. It must be an integer. This worries me. If you're debugging
by duckerude 6y ago
> version is used to track versions of macros, so that generated bytecodes can be correctly cached. It must be an integer.
This worries me. If you're debugging a macro, you have to remember to increment the version every time you change it, or your changes mysteriously don't take effect. And you have to make sure your macros are clean and deterministic or you might bake things into the cache that don't belong there.
> The syntax tree of Python is available through the ast module.
That module can be annoying to work with because it doesn't make stability guarantees. I've even had to deal with code that broke in a maintenance release (3.8.4) because of this change: https://bugs.python.org/issue40870 https://bugs.python.org/issue40870
I can't think of any better alternatives, besides doing nothing. But it looks like it'll be unusually easy to use wrong, not to be used lightly.
- heavenlyblue 6y agoThat’s why you provide well-featured transparent debugging facilities.
- jsjohnst 6y agoI’ve not read the proposal in full (skimmed it, so might’ve missed something admittedly), but if you were debugging a macro you wrote, why not just blow away the pyc files each iteration vs incrementing the version? I see the version increment more for when you distribute the macro.
- duckerude 6y agoYeah, that's probably more practical. Or a wrapper that uses a timestamp as the version so it's always higher than last run. Still—one more thing you have to remember.