Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e3f359c7
Commit
e3f359c7
authored
Dec 28, 2015
by
Stefan Krah
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
53f2e0ad
3f1b95b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
Lib/test/test_functools.py
Lib/test/test_functools.py
+12
-2
Misc/NEWS
Misc/NEWS
+4
-0
Modules/_functoolsmodule.c
Modules/_functoolsmodule.c
+16
-0
No files found.
Lib/test/test_functools.py
View file @
e3f359c7
...
...
@@ -1262,14 +1262,24 @@ class TestLRU:
def
test_copy
(
self
):
cls
=
self
.
__class__
for
f
in
cls
.
cached_func
[
0
],
cls
.
cached_meth
,
cls
.
cached_staticmeth
:
def
orig
(
x
,
y
):
return
3
*
x
+
y
part
=
self
.
module
.
partial
(
orig
,
2
)
funcs
=
(
cls
.
cached_func
[
0
],
cls
.
cached_meth
,
cls
.
cached_staticmeth
,
self
.
module
.
lru_cache
(
2
)(
part
))
for
f
in
funcs
:
with
self
.
subTest
(
func
=
f
):
f_copy
=
copy
.
copy
(
f
)
self
.
assertIs
(
f_copy
,
f
)
def
test_deepcopy
(
self
):
cls
=
self
.
__class__
for
f
in
cls
.
cached_func
[
0
],
cls
.
cached_meth
,
cls
.
cached_staticmeth
:
def
orig
(
x
,
y
):
return
3
*
x
+
y
part
=
self
.
module
.
partial
(
orig
,
2
)
funcs
=
(
cls
.
cached_func
[
0
],
cls
.
cached_meth
,
cls
.
cached_staticmeth
,
self
.
module
.
lru_cache
(
2
)(
part
))
for
f
in
funcs
:
with
self
.
subTest
(
func
=
f
):
f_copy
=
copy
.
deepcopy
(
f
)
self
.
assertIs
(
f_copy
,
f
)
...
...
Misc/NEWS
View file @
e3f359c7
...
...
@@ -125,6 +125,10 @@ Library
- Issue #25928: Add Decimal.as_integer_ratio().
- Issue #25447: Copying the lru_cache() wrapper object now always works,
independedly from the type of the wrapped object (by returning the original
object unchanged).
- Issue #25768: Have the functions in compileall return booleans instead of
ints and add proper documentation and tests for the return values.
...
...
Modules/_functoolsmodule.c
View file @
e3f359c7
...
...
@@ -1053,6 +1053,20 @@ lru_cache_reduce(PyObject *self, PyObject *unused)
return
PyObject_GetAttrString
(
self
,
"__qualname__"
);
}
static
PyObject
*
lru_cache_copy
(
PyObject
*
self
,
PyObject
*
unused
)
{
Py_INCREF
(
self
);
return
self
;
}
static
PyObject
*
lru_cache_deepcopy
(
PyObject
*
self
,
PyObject
*
unused
)
{
Py_INCREF
(
self
);
return
self
;
}
static
int
lru_cache_tp_traverse
(
lru_cache_object
*
self
,
visitproc
visit
,
void
*
arg
)
{
...
...
@@ -1104,6 +1118,8 @@ static PyMethodDef lru_cache_methods[] = {
{
"cache_info"
,
(
PyCFunction
)
lru_cache_cache_info
,
METH_NOARGS
},
{
"cache_clear"
,
(
PyCFunction
)
lru_cache_cache_clear
,
METH_NOARGS
},
{
"__reduce__"
,
(
PyCFunction
)
lru_cache_reduce
,
METH_NOARGS
},
{
"__copy__"
,
(
PyCFunction
)
lru_cache_copy
,
METH_VARARGS
},
{
"__deepcopy__"
,
(
PyCFunction
)
lru_cache_deepcopy
,
METH_VARARGS
},
{
NULL
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment