-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cythonize reify #2995
Cythonize reify #2995
Changes from all commits
30c8c0a
5e1c54d
b269f3b
9ac799f
f78155f
ff020ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ script: | |
- make cov-ci-run | ||
|
||
after_success: | ||
- codecov | ||
# - codecov | ||
- bash <(curl -s https://codecov.io/bash) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do this? we install it in CI pinned to certain version: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was my try to fix coverage reports. |
||
|
||
_helpers: | ||
- &_mainstream_python_base | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cythonize ``@helpers.reify``, 5% boost on macro benchmark |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cdef class reify: | ||
"""Use as a class method decorator. It operates almost exactly like | ||
the Python `@property` decorator, but it puts the result of the | ||
method it decorates into the instance dict after the first call, | ||
effectively replacing the function it decorates with an instance | ||
variable. It is, in Python parlance, a data descriptor. | ||
""" | ||
|
||
cdef object wrapped | ||
cdef object name | ||
|
||
def __init__(self, wrapped): | ||
self.wrapped = wrapped | ||
self.name = wrapped.__name__ | ||
|
||
@property | ||
def __doc__(self): | ||
return self.wrapped.__doc__ | ||
|
||
def __get__(self, inst, owner): | ||
try: | ||
try: | ||
return inst._cache[self.name] | ||
except KeyError: | ||
val = self.wrapped(inst) | ||
inst._cache[self.name] = val | ||
return val | ||
except AttributeError: | ||
if inst is None: | ||
return self | ||
raise | ||
|
||
def __set__(self, inst, value): | ||
raise AttributeError("reified property is read-only") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ ctor | |
Ctrl | ||
Cython | ||
cythonized | ||
Cythonize | ||
de | ||
deduplicate | ||
# de-facto: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asvetlov it looks like you forgot to update MANIFEST.in.
I wish we could just use a setuptools plugin, which would rely on git to do this automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.c
files should be included but*.html
should not.Not very big problem though: on travis html files are never generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by ffa4532