benchmark
50b26503 - Split DequeIteratorVariable off ListIteratorVariable to match CPython (#193261)

Commit
94 days ago
Split DequeIteratorVariable off ListIteratorVariable to match CPython (#193261) Summary: ## Summary In CPython, `_deque_iterator` is not a subclass of `list_iterator`, but Dynamo modeled `DequeIteratorVariable` as a subclass of `ListIteratorVariable`. This aligns the VariableTracker hierarchy with CPython. Part of #192874. ## Fix `DequeIteratorVariable` now inherits `IteratorVariable` directly instead of `ListIteratorVariable`, mirroring CPython where `_deque_iterator` and `list_iterator` are siblings. It carries its own iterate-over-materialized-items logic plus the existing per-step mutation check. `TupleIteratorVariable` stays a `ListIteratorVariable` subclass (matches CPython). Breaking the subclass link touches three `isinstance(x, ListIteratorVariable)` sites that previously matched deque iterators transitively: - `GET_YIELD_FROM_ITER` now checks `(ListIteratorVariable, DequeIteratorVariable)` so list, tuple, and deque keep the same `yield from` behavior. - `_unpack_fast_types` re-adds `DequeIteratorVariable` so deque iterators keep the fast `unpack_var_sequence` path instead of the generic iterator protocol. - The `list_iterator_mutation` side-effect replay handler is source-based; deque iterators are always built sourceless with `ValueMutationNew` and never reached it, so no change is needed there. ## Test Plan ``` python test/dynamo/test_iterators.py TestIterators.test_deque_iterator_not_a_list_iterator python test/dynamo/test_iterators.py TestIterators.test_yield_from_deque_iterator python test/dynamo/test_iterators.py ``` Authored with an AI assistant. X-link: https://github.com/pytorch/pytorch/pull/193261 Approved by: https://github.com/guilhermeleobas Reviewed By: jeanschmidt Differential Revision: D116640619 fbshipit-source-id: 4cea3cee2f1e89db65d2748d7dfc0d75b27d27ee
Author
generatedunixname499836121
Committer
Parents
Loading