Add optimization for Injection.value property

This commit is contained in:
Roman Mogilatov 2015-10-19 10:50:17 +03:00
parent 53025756d8
commit c13bee6fb5
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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