Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 5fbf322afc5d44e429ab61a5f65ca46dddb07233 1 parent 92350f7
@jtackaberry jtackaberry authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/callable.py
View
6 src/callable.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.