You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it stands, this function unites a number of disparate functionalities. Not only that, but the functionalities depend on the type of the first parameter object. It might be possible for it to benefit from breaking it up via @functools.singledispatch. The single dispatch decorator operates on the first parameter's type, which looks to me to be what the function in question does.
The flip side is that I'm not sure about the performance costs of doing such a thing. Having a new branch can be a cheap way to test it, since a branch can always be ignored/deleted later on.
Even if single dispatch turns out to not be worth it, I still think that, for code maintenance, the function might benefit from breaking it up into sub-functions (which are then called from the "head" function).
Edit: If such a move will be deemed as beneficial I don't mind making a PR for it.
The text was updated successfully, but these errors were encountered:
Solomon1732
changed the title
Possibly use functools' single dispatch to break up a function into subfunctions
Possibly break up a function into subfunctions
Feb 18, 2021
Thanks for your suggestion! I'm not even sure if we want to keep that json_util file since it was mostly for Python 3 compatibility (when we migrated from Python 2).
anydex-core/anydex/util/json_util.py
Line 21 in deeb9b3
As it stands, this function unites a number of disparate functionalities. Not only that, but the functionalities depend on the type of the first parameter object. It might be possible for it to benefit from breaking it up via
@functools.singledispatch
. The single dispatch decorator operates on the first parameter's type, which looks to me to be what the function in question does.The flip side is that I'm not sure about the performance costs of doing such a thing. Having a new branch can be a cheap way to test it, since a branch can always be ignored/deleted later on.
Even if single dispatch turns out to not be worth it, I still think that, for code maintenance, the function might benefit from breaking it up into sub-functions (which are then called from the "head" function).
Edit: If such a move will be deemed as beneficial I don't mind making a PR for it.
The text was updated successfully, but these errors were encountered: