Skip to content

Commit

Permalink
A faster identity function from cytoolz
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Sep 20, 2017
1 parent 105a06d commit 34011e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ def _read(fname):
'zope.security',
],
extras_require={
':platform_python_implementation=="CPython"': [
'cytoolz >= 0.8.2',
],
':platform_python_implementation=="PyPy"': [
'toolz',
],
'test': TESTS_REQUIRE,
'docs': [
'Sphinx',
'repoze.sphinx.autointerface',
'sphinx_rtd_theme',
]
],

},
entry_points=entry_points,
)
9 changes: 7 additions & 2 deletions src/nti/externalization/externalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import persistent
import six

try:
from cytoolz import identity
except ImportError: # PyPy pragma: no cover
from toolz import identity

from zope import component
from zope import deprecation
from zope import interface
Expand Down Expand Up @@ -400,9 +405,9 @@ def datetime_to_epoch(dt):


def choose_field(result, self, ext_name,
converter=lambda _: _,
converter=identity,
fields=(),
sup_iface=None, sup_fields=(), sup_converter=lambda _: _):
sup_iface=None, sup_fields=(), sup_converter=identity):

for x in fields:
try:
Expand Down

0 comments on commit 34011e4

Please sign in to comment.