Browse files

Do not store function name in __init__

This optimizes Callable instantiation when str(func) is expensive (like in
the case of InProgress objects).  This was added to improve debugging for
WeakCallables, but the use-cases for a traceback being insufficient are few
so we'll take the optimization win.
  • Loading branch information...
1 parent 92350f7 commit 5fbf322afc5d44e429ab61a5f65ca46dddb07233 @jtackaberry jtackaberry committed Jan 19, 2012
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/
@@ -125,9 +125,7 @@ def __init__(self, func, *args, **kwargs):
:param kwargs: keyword arguments to be passed to func when invoked
super(Callable, self).__init__()
- assert(callable(func))
self._func = func
- self._func_name = str(func)
self._args = args
self._kwargs = kwargs
self._ignore_caller_args = False
@@ -219,8 +217,8 @@ def __call__(self, *args, **kwargs):
The wrapped callable's return value is returned.
cb = self._get_func()
- if not cb:
- raise CallableError('The Callable (%s) has become invalid.' % self._func_name)
+ if cb is None:
+ raise CallableError('attempting to invoke an invalid callable')
cb_args, cb_kwargs = self._merge_args(args, kwargs)
return cb(*cb_args, **cb_kwargs)

0 comments on commit 5fbf322

Please sign in to comment.