When designing a callable object, we need to consider the following:
- The first consideration is the interface of the object. If there's a reason for the object to have a function-like interface, then a callable object is a sensible design approach. Using collections.abc.Callable assures that the callable API is built correctly, and it informs anyone reading the code what the intent of the class is.
- The secondary consideration is the statefulness of the function. Ordinary functions in Python have no hysteresis – there's no saved state. A callable object, however, can easily save a state. The memoization design pattern makes good use of stateful callable objects.
The only disadvantage of a callable ...