-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleanup * Implement cythonized reify decorator * Add changelog * reify more props * Fix spelling * Use bash version of codecov uploader
- Loading branch information
Showing
9 changed files
with
86 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cythonize ``@helpers.reify``, 5% boost on macro benchmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ ctor | |
Ctrl | ||
Cython | ||
cythonized | ||
Cythonize | ||
de | ||
deduplicate | ||
# de-facto: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters