app: Don't check Python version for every request
Checking for the `basestring` name takes a nonzero amount of time, the result of the check never changes. As such, is not appropriate to do this for every request.master
parent
71d00e4207
commit
ff27f3a917
|
@ -40,6 +40,14 @@ __all__ = [
|
|||
]
|
||||
|
||||
|
||||
try:
|
||||
# In Python 2, it could be a str or a unicode object
|
||||
_string = basestring
|
||||
except NameError:
|
||||
# In Python 3, we are only interested in str objects
|
||||
_string = str
|
||||
|
||||
|
||||
class BaseApplication(object):
|
||||
'''Base class for Milla applications
|
||||
|
||||
|
@ -88,12 +96,6 @@ class BaseApplication(object):
|
|||
|
||||
# The callable might have returned just a string, which is OK,
|
||||
# but we need to wrap it in a Response object
|
||||
try:
|
||||
# In Python 2, it could be a str or a unicode object
|
||||
_string = basestring
|
||||
except NameError:
|
||||
# In Python 3, we are only interested in str objects
|
||||
_string = str
|
||||
if isinstance(response, _string) or not response:
|
||||
response = request.ResponseClass(response)
|
||||
|
||||
|
|
Loading…
Reference in New Issue