mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 17:47:02 +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."""
|
||||
|
||||
__IS_INJECTION__ = True
|
||||
__slots__ = ('name', 'injectable')
|
||||
__slots__ = ('name', 'injectable', 'is_provider')
|
||||
|
||||
def __init__(self, name, injectable):
|
||||
"""Initializer."""
|
||||
self.name = name
|
||||
self.injectable = injectable
|
||||
self.is_provider = is_provider(injectable)
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""Return injectable value."""
|
||||
if is_provider(self.injectable):
|
||||
if self.is_provider:
|
||||
return self.injectable()
|
||||
return self.injectable
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ Development version
|
|||
examples.
|
||||
- Add support of Python 3.5.
|
||||
- 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.
|
||||
|
||||
0.9.5
|
||||
|
|
Loading…
Reference in New Issue
Block a user