mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-100117: Make co_lines
more efficient (GH-100447)
This commit is contained in:
parent
b2f7b2ef0b
commit
f07daaf4f7
4 changed files with 26 additions and 38 deletions
|
@ -161,9 +161,8 @@ if 1:
|
|||
s256 = "".join(["\n"] * 256 + ["spam"])
|
||||
co = compile(s256, 'fn', 'exec')
|
||||
self.assertEqual(co.co_firstlineno, 1)
|
||||
lines = list(co.co_lines())
|
||||
self.assertEqual(lines[0][2], 0)
|
||||
self.assertEqual(lines[1][2], 257)
|
||||
lines = [line for _, _, line in co.co_lines()]
|
||||
self.assertEqual(lines, [0, 257])
|
||||
|
||||
def test_literals_with_leading_zeroes(self):
|
||||
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
|
||||
|
@ -955,9 +954,9 @@ if 1:
|
|||
for func in (no_code1, no_code2):
|
||||
with self.subTest(func=func):
|
||||
code = func.__code__
|
||||
lines = list(code.co_lines())
|
||||
start, end, line = lines[0]
|
||||
[(start, end, line)] = code.co_lines()
|
||||
self.assertEqual(start, 0)
|
||||
self.assertEqual(end, len(code.co_code))
|
||||
self.assertEqual(line, code.co_firstlineno)
|
||||
|
||||
def get_code_lines(self, code):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue