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
f36f8925
Commit
f36f8925
authored
Feb 21, 2019
by
Joe Jevnik
Committed by
Raymond Hettinger
Feb 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36068: Make _tuplegetter objects serializable (GH-11981)
parent
407c7343
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
Doc/whatsnew/3.8.rst
Doc/whatsnew/3.8.rst
+1
-1
Lib/test/test_collections.py
Lib/test/test_collections.py
+10
-1
Modules/_collectionsmodule.c
Modules/_collectionsmodule.c
+12
-1
No files found.
Doc/whatsnew/3.8.rst
View file @
f36f8925
...
...
@@ -368,7 +368,7 @@ Optimizations
* Sped-up field lookups in :func:`collections.namedtuple`. They are now more
than two times faster, making them the fastest form of instance variable
lookup in Python. (Contributed by Raymond Hettinger, Pablo Galindo, and
Serhiy Storchaka in :issue:`32492`.)
Joe Jevnik,
Serhiy Storchaka in :issue:`32492`.)
* The :class:`list` constructor does not overallocate the internal item buffer
if the input iterable has a known length (the input implements ``__len__``).
...
...
Lib/test/test_collections.py
View file @
f36f8925
...
...
@@ -13,7 +13,7 @@ from test import support
import
types
import
unittest
from
collections
import
namedtuple
,
Counter
,
OrderedDict
,
_count_elements
from
collections
import
namedtuple
,
Counter
,
OrderedDict
,
_count_elements
,
_tuplegetter
from
collections
import
UserDict
,
UserString
,
UserList
from
collections
import
ChainMap
from
collections
import
deque
...
...
@@ -573,6 +573,15 @@ class TestNamedTuple(unittest.TestCase):
self
.
assertRaises
(
AttributeError
,
Point
.
x
.
__set__
,
p
,
33
)
self
.
assertRaises
(
AttributeError
,
Point
.
x
.
__delete__
,
p
)
class
NewPoint
(
tuple
):
x
=
pickle
.
loads
(
pickle
.
dumps
(
Point
.
x
))
y
=
pickle
.
loads
(
pickle
.
dumps
(
Point
.
y
))
np
=
NewPoint
([
1
,
2
])
self
.
assertEqual
(
np
.
x
,
1
)
self
.
assertEqual
(
np
.
y
,
2
)
################################################################################
### Abstract Base Classes
...
...
Modules/_collectionsmodule.c
View file @
f36f8925
...
...
@@ -2440,12 +2440,23 @@ tuplegetter_dealloc(_tuplegetterobject *self)
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
}
static
PyObject
*
tuplegetter_reduce
(
_tuplegetterobject
*
self
)
{
return
Py_BuildValue
(
"(O(nO))"
,
(
PyObject
*
)
Py_TYPE
(
self
),
self
->
index
,
self
->
doc
);
}
static
PyMemberDef
tuplegetter_members
[]
=
{
{
"__doc__"
,
T_OBJECT
,
offsetof
(
_tuplegetterobject
,
doc
),
0
},
{
0
}
};
static
PyMethodDef
tuplegetter_methods
[]
=
{
{
"__reduce__"
,
(
PyCFunction
)
tuplegetter_reduce
,
METH_NOARGS
,
NULL
},
{
NULL
},
};
static
PyTypeObject
tuplegetter_type
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"_collections._tuplegetter"
,
/* tp_name */
...
...
@@ -2475,7 +2486,7 @@ static PyTypeObject tuplegetter_type = {
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_methods */
tuplegetter_methods
,
/* tp_methods */
tuplegetter_members
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
...
...
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