mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 17:39:48 +03:00
Simplify is_simple_callable() and make it faster and more general
This function shows up in some profiles. callable() is a fast builtin function. It covers the existing checks and all others as well. inspect.signature() accepts any callable.
This commit is contained in:
parent
564faddb0f
commit
5acdf51c7d
|
@ -1,7 +1,6 @@
|
|||
import copy
|
||||
import datetime
|
||||
import decimal
|
||||
import functools
|
||||
import inspect
|
||||
import re
|
||||
import uuid
|
||||
|
@ -53,7 +52,7 @@ def is_simple_callable(obj):
|
|||
"""
|
||||
True if the object is a callable that takes no arguments.
|
||||
"""
|
||||
if not (inspect.isfunction(obj) or inspect.ismethod(obj) or isinstance(obj, functools.partial)):
|
||||
if not callable(obj):
|
||||
return False
|
||||
|
||||
sig = inspect.signature(obj)
|
||||
|
|
Loading…
Reference in New Issue
Block a user