瀏覽代碼

Adds comment to head_from_fun

Ask Solem 8 年之前
父節點
當前提交
ece3222859
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      celery/utils/functional.py

+ 5 - 0
celery/utils/functional.py

@@ -245,6 +245,11 @@ def _argsfromspec(spec, replace_defaults=True):
 
 
 
 
 def head_from_fun(fun, bound=False, debug=False):
 def head_from_fun(fun, bound=False, debug=False):
+    # we could use inspect.Signature here, but that implementation
+    # is very slow since it implements the argument checking
+    # in pure-Python.  Instead we use exec to create a new function
+    # with an empty body, meaning it has the same performance as
+    # as just calling a function.
     if not isfunction(fun) and hasattr(fun, '__call__'):
     if not isfunction(fun) and hasattr(fun, '__call__'):
         name, fun = fun.__class__.__name__, fun.__call__
         name, fun = fun.__class__.__name__, fun.__call__
     else:
     else: