4 ms·
Yeah 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 no
by mpeg 3y ago
Yeah 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