* [PATCH] Update use of deque in _frame_iterator
@ 2026-06-03 0:26 Tom Tromey
2026-06-22 22:16 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2026-06-03 0:26 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
_frame_iterator has an old comment about some hand-written code that
was needed when supporting Python 2.6. This patch simplifies the code
by using a couple of features of collections.deque.
---
gdb/python/lib/gdb/frames.py | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/gdb/python/lib/gdb/frames.py b/gdb/python/lib/gdb/frames.py
index de954e4fb38..6539416b1c2 100644
--- a/gdb/python/lib/gdb/frames.py
+++ b/gdb/python/lib/gdb/frames.py
@@ -186,18 +186,7 @@ def _frame_iterator(frame, frame_low, frame_high, dap_semantics):
# Is this a slice from the end of the backtrace, ie bt -2?
if frame_low < 0:
- count = 0
- slice_length = abs(frame_low)
- # We cannot use MAXLEN argument for deque as it is 2.6 onwards
- # and some GDB versions might be < 2.6.
- sliced = collections.deque()
-
- for frame_item in frame_iterator:
- if count >= slice_length:
- sliced.popleft()
- count = count + 1
- sliced.append(frame_item)
-
+ sliced = collections.deque(iterable=frame_iterator, maxlen=abs(frame_low))
return iter(sliced)
# -1 for frame_high means until the end of the backtrace. Set to
--
2.49.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Update use of deque in _frame_iterator
2026-06-03 0:26 [PATCH] Update use of deque in _frame_iterator Tom Tromey
@ 2026-06-22 22:16 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2026-06-22 22:16 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> _frame_iterator has an old comment about some hand-written code that
Tom> was needed when supporting Python 2.6. This patch simplifies the code
Tom> by using a couple of features of collections.deque.
I'm checking this in now.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-22 22:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-03 0:26 [PATCH] Update use of deque in _frame_iterator Tom Tromey
2026-06-22 22:16 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox