mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-04 20:33:13 +03:00
Add optimization for Injection.value
property
This commit is contained in:
parent
53025756d8
commit
c13bee6fb5
|
@ -21,17 +21,18 @@ class Injection(object):
|
||||||
"""Base injection class."""
|
"""Base injection class."""
|
||||||
|
|
||||||
__IS_INJECTION__ = True
|
__IS_INJECTION__ = True
|
||||||
__slots__ = ('name', 'injectable')
|
__slots__ = ('name', 'injectable', 'is_provider')
|
||||||
|
|
||||||
def __init__(self, name, injectable):
|
def __init__(self, name, injectable):
|
||||||
"""Initializer."""
|
"""Initializer."""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.injectable = injectable
|
self.injectable = injectable
|
||||||
|
self.is_provider = is_provider(injectable)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
"""Return injectable value."""
|
"""Return injectable value."""
|
||||||
if is_provider(self.injectable):
|
if self.is_provider:
|
||||||
return self.injectable()
|
return self.injectable()
|
||||||
return self.injectable
|
return self.injectable
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ Development version
|
||||||
examples.
|
examples.
|
||||||
- Add support of Python 3.5.
|
- Add support of Python 3.5.
|
||||||
- Add support of six 1.10.0.
|
- Add support of six 1.10.0.
|
||||||
|
- Add optimization for ``di.Injection.value`` property that will compute
|
||||||
|
type of injection once, instead of doing this on every call.
|
||||||
- Add minor refactorings and code style fixes.
|
- Add minor refactorings and code style fixes.
|
||||||
|
|
||||||
0.9.5
|
0.9.5
|
||||||
|
|
Loading…
Reference in New Issue
Block a user