summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2018-12-30 09:24:03 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2018-12-30 09:24:03 (GMT)
commit3f5fc70c6213008243e7d605f7d8a2d8f94cf919 (patch)
tree44c396f3a052803c4725eec2e6ccb1ab32529c8f /Lib/test/test_collections.py
parentb0a6196ffd58ff91462191f426706897dc920eee (diff)
downloadcpython-3f5fc70c6213008243e7d605f7d8a2d8f94cf919.zip
cpython-3f5fc70c6213008243e7d605f7d8a2d8f94cf919.tar.gz
cpython-3f5fc70c6213008243e7d605f7d8a2d8f94cf919.tar.bz2
bpo-32492: 1.6x speed up in namedtuple attribute access using C fast-path (#10495)
* bpo-32492: 2.5x speed up in namedtuple attribute access using C fast path * Add News entry * fixup! bpo-32492: 2.5x speed up in namedtuple attribute access using C fast path * Check for tuple in the __get__ of the new descriptor and don't cache the descriptor itself * Don't inherit from property. Implement GC methods to handle __doc__ * Add a test for the docstring substitution in descriptors * Update NEWS entry to reflect time against 3.7 branch * Simplify implementation with argument clinic, better error messages, only __new__ * Use positional-only parameters for the __new__ * Use PyTuple_GET_SIZE and PyTuple_GET_ITEM to tighter the implementation of tuplegetterdescr_get * Implement __set__ to make tuplegetter a data descriptor * Use Py_INCREF now that we inline PyTuple_GetItem * Apply the valid_index() function, saving one test * Move Py_None test out of the critical path.
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index e2ffaaa..c081594 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -514,6 +514,14 @@ class TestNamedTuple(unittest.TestCase):
a.w = 5
self.assertEqual(a.__dict__, {'w': 5})
+ def test_namedtuple_can_mutate_doc_of_descriptors_independently(self):
+ A = namedtuple('A', 'x y')
+ B = namedtuple('B', 'x y')
+ A.x.__doc__ = 'foo'
+ B.x.__doc__ = 'bar'
+ self.assertEqual(A.x.__doc__, 'foo')
+ self.assertEqual(B.x.__doc__, 'bar')
+
################################################################################
### Abstract Base Classes