3 ms·
Making the __dict__ opt-in makes it a lot more user-friendly at the expense of a little verbosity. That makes sense. These tips make sense, we often use named
by williamzeng0 3y ago
Making the __dict__ opt-in makes it a lot more user-friendly at the expense of a little verbosity. That makes sense.
These tips make sense, we often use named args in our function calls (not using them has caused so many bugs), but we don't really enforce the order. Copilot doesn't always get it right either.
By moving inspect.getsource out of the wrapper, do you mean initializing it when the module is imported? I'm curious how that improves performance.
- mpeg 3y agoYeah I too try to avoid positional args as much as possible, huge source of bugs and time wasting especially when refactoring code Re inspect.getsource, I'm not sure if it'd be a huge performance impact, but if it's in the wrapper fn it will get called every time the function gets called, while if it's outside it will be called only when the decorator runs (eg when the module containing the function being decorated is imported). eg: https://gist.github.com/mpeg/ff1d99fde06f39916b5aaadd76b534f4 https://gist.github.com/mpeg/ff1d99fde06f39916b5aaadd76b534f... EDIT: on a quick test, over 100k function calls, with inspect.getsource inside the wrapper it runs in 2.7s on my Apple M2, and that's not even including the md5 hash, so I suspect this should dramatically improve performance for you
- williamzeng0 3y agoThis is great, thanks for the suggestion! We've just updated our docs and code with this change: https://github.com/sweepai/sweep/pull/3332 https://github.com/sweepai/sweep/pull/3332