Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if other.class().is(vm.ctx.types.dict_type) | ||
| && let Ok(other) = other.downcast::<PyDict>() |
There was a problem hiding this comment.
still there is convenience problem, but we have downcast_exact
| } | ||
|
|
||
| // ============================================================================ | ||
| // OrderedDict implementation |
There was a problem hiding this comment.
If this type is comparably big to this module crates/vm/src/stdlib/collections/ordered_dict.rs?
Assisted-by: Codex:gpt-5.6-sol
Assisted-by: Codex:gpt-5.6-sol
Keep order-changing operations compact and track structural mutations for atomic OrderedDict iteration checks. Assisted-by: Codex:gpt-5.6-sol
Preserve ordinary dict-subclass unions and implement direction-aware set operations for dict and OrderedDict item views. Assisted-by: Codex:gpt-5.6-sol
Route mutating operations through subclass hooks, preserve recursive pickle behavior, support __missing__, and make comparison and copy mutation-safe. Assisted-by: Codex:gpt-5.6-sol
Add set-like mapping views, ABC registration, GC traversal, mutation-safe iteration, and iterator pickling. Assisted-by: Codex:gpt-5.6-sol
Remove expected-failure markers for mutation detection, copy safety, and iterator pickling now covered by the native implementation. Assisted-by: Codex:gpt-5.6-sol
Let the inherited OrderedDict test cover recursive pickling now that the native implementation passes it. Assisted-by: Codex:gpt-5.6-sol
e4b1793 to
d137278
Compare
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/codecs.py dependencies:
dependent tests: (161 tests)
[x] test: cpython/Lib/test/test_tstring.py (TODO: 3) dependencies: dependent tests: (no tests depend on tstring) [x] test: cpython/Lib/test/test_coroutines.py (TODO: 18) dependencies: dependent tests: (7 tests) [x] test: cpython/Lib/test/test_zlib.py (TODO: 2) dependencies: dependent tests: (104 tests)
[x] lib: cpython/Lib/socket.py dependencies:
dependent tests: (101 tests)
[ ] lib: cpython/Lib/xml dependencies:
dependent tests: (34 tests)
[x] lib: cpython/Lib/threading.py dependencies:
dependent tests: (166 tests)
[x] lib: cpython/Lib/contextlib.py dependencies:
dependent tests: (83 tests)
[ ] test: cpython/Lib/test/test_str.py (TODO: 5) dependencies: dependent tests: (no tests depend on str) [x] test: cpython/Lib/test/test_float.py (TODO: 2) dependencies: dependent tests: (no tests depend on float) [x] test: cpython/Lib/test/test_gc.py (TODO: 2) dependencies: dependent tests: (184 tests)
[x] lib: cpython/Lib/doctest.py dependencies:
dependent tests: (36 tests)
[ ] lib: cpython/Lib/multiprocessing dependencies:
dependent tests: (11 tests)
[ ] test: cpython/Lib/test/test_class.py (TODO: 12) dependencies: dependent tests: (no tests depend on class) [ ] test: cpython/Lib/test/test_generators.py (TODO: 9) dependencies: dependent tests: (no tests depend on generator) [x] lib: cpython/Lib/codeop.py dependencies:
dependent tests: (105 tests)
[x] lib: cpython/Lib/enum.py dependencies:
dependent tests: (16 tests)
[ ] test: cpython/Lib/test/test_pyrepl (TODO: 22) dependencies: dependent tests: (no tests depend on pyrepl) [ ] lib: cpython/Lib/sqlite3 dependencies:
dependent tests: (2 tests)
[ ] test: cpython/Lib/test/test_unicodedata.py (TODO: 28) dependencies: dependent tests: (no tests depend on unicode) [x] test: cpython/Lib/test/test_cmd_line_script.py (TODO: 13) dependencies: dependent tests: (no tests depend on cmd_line_script) [x] lib: cpython/Lib/io.py dependencies:
dependent tests: (108 tests)
[x] lib: cpython/Lib/_pylong.py dependencies:
dependent tests: (no tests depend on int) [x] test: cpython/Lib/test/test_compile.py dependencies: dependent tests: (no tests depend on compile) [x] lib: cpython/Lib/ssl.py dependencies:
dependent tests: (54 tests)
[x] lib: cpython/Lib/tempfile.py dependencies:
dependent tests: (94 tests)
[x] lib: cpython/Lib/pdb.py dependencies:
dependent tests: (1 tests)
[x] test: cpython/Lib/test/test_select.py (TODO: 3) dependencies: dependent tests: (109 tests)
[x] test: cpython/Lib/test/test_asyncgen.py (TODO: 4) dependencies: dependent tests: (no tests depend on asyncgen) [x] test: cpython/Lib/test/test_frame.py (TODO: 4) dependencies: dependent tests: (no tests depend on frame) [ ] test: cpython/Lib/test/test_exceptions.py (TODO: 21) dependencies: dependent tests: (no tests depend on exception) [x] lib: cpython/Lib/xmlrpc dependencies:
dependent tests: (4 tests)
[x] lib: cpython/Lib/bz2.py dependencies:
dependent tests: (102 tests)
[x] lib: cpython/Lib/plistlib.py dependencies:
dependent tests: (25 tests)
[x] lib: cpython/Lib/traceback.py dependencies:
dependent tests: (162 tests)
[ ] lib: cpython/Lib/unittest dependencies:
dependent tests: (408 tests)
[x] lib: cpython/Lib/email dependencies: dependent tests: (54 tests)
[x] lib: cpython/Lib/inspect.py dependencies:
dependent tests: (97 tests)
[x] lib: cpython/Lib/pickle.py dependencies:
dependent tests: (102 tests)
[ ] test: cpython/Lib/test/test_termios.py (TODO: 1) dependencies: dependent tests: (8 tests)
[ ] lib: cpython/Lib/collections dependencies:
dependent tests: (332 tests)
[ ] test: cpython/Lib/test/test_cmd_line.py (TODO: 24) dependencies: dependent tests: (no tests depend on cmd_line) [ ] lib: cpython/Lib/asyncio dependencies:
dependent tests: (7 tests)
[x] test: cpython/Lib/test/test_list.py (TODO: 3) dependencies: dependent tests: (no tests depend on list) [ ] test: cpython/Lib/test/test_sys.py (TODO: 7) dependencies: dependent tests: (241 tests)
[ ] test: cpython/Lib/test/test_monitoring.py (TODO: 5) dependencies: dependent tests: (no tests depend on monitoring) [x] lib: cpython/Lib/pty.py dependencies:
dependent tests: (4 tests)
[ ] lib: cpython/Lib/http dependencies:
dependent tests: (51 tests)
[x] lib: cpython/Lib/importlib dependencies:
dependent tests: (128 tests)
[ ] test: cpython/Lib/test/test_mmap.py (TODO: 25) dependencies: dependent tests: (2 tests)
[ ] test: cpython/Lib/test/test_bytes.py (TODO: 18) dependencies: dependent tests: (no tests depend on bytes) [x] lib: cpython/Lib/lzma.py dependencies:
dependent tests: (102 tests)
[x] test: cpython/Lib/test/test_print.py (TODO: 6) dependencies: dependent tests: (no tests depend on print) [x] test: cpython/Lib/test/test_builtin.py (TODO: 15) dependencies: dependent tests: (no tests depend on builtin) [x] lib: cpython/Lib/re dependencies:
dependent tests: (82 tests)
[x] test: cpython/Lib/test/test_descr.py (TODO: 31) dependencies: dependent tests: (no tests depend on descr) [ ] lib: cpython/Lib/test/libregrtest dependencies:
dependent tests: (no tests depend on regrtest) [ ] test: cpython/Lib/test/test_posix.py (TODO: 5) dependencies: dependent tests: (102 tests)
[x] lib: cpython/Lib/trace.py dependencies:
dependent tests: (1 tests)
[x] test: cpython/Lib/test/test_memoryview.py (TODO: 1) dependencies: dependent tests: (no tests depend on memoryview) [x] lib: cpython/Lib/hashlib.py dependencies:
dependent tests: (146 tests)
[x] test: cpython/Lib/test/test_context.py (TODO: 7) dependencies: dependent tests: (11 tests) [x] lib: cpython/Lib/zipfile dependencies:
dependent tests: (99 tests)
[x] test: cpython/Lib/test/test_winconsoleio.py (TODO: 1) dependencies: dependent tests: (no tests depend on winconsoleio) [x] test: cpython/Lib/test/test_range.py (TODO: 3) dependencies: dependent tests: (no tests depend on range) [x] test: cpython/Lib/test/test_resource.py (TODO: 3) dependencies: dependent tests: (4 tests)
[x] lib: cpython/Lib/types.py dependencies:
dependent tests: (57 tests)
[ ] lib: cpython/Lib/concurrent dependencies:
dependent tests: (17 tests)
[x] lib: cpython/Lib/pydoc.py dependencies:
dependent tests: (5 tests)
[ ] test: cpython/Lib/test/test_syntax.py (TODO: 64) dependencies: dependent tests: (no tests depend on syntax) [x] lib: cpython/Lib/pyclbr.py dependencies:
dependent tests: (1 tests)
[ ] lib: cpython/Lib/json dependencies:
dependent tests: (13 tests)
[x] test: cpython/Lib/test/test_super.py (TODO: 2) dependencies: dependent tests: (no tests depend on super) [ ] lib: cpython/Lib/logging dependencies:
dependent tests: (90 tests)
[x] lib: cpython/Lib/struct.py dependencies:
dependent tests: (179 tests)
[x] lib: cpython/Lib/subprocess.py dependencies:
dependent tests: (87 tests)
Legend:
|
d137278 to
a614356
Compare
|
It may be replaced with #8780 |
|
@moreal hey I missed this is revised. do you want to finish this? |
@youknowone No, I just remembered a PR I opened a while back and then closed. Since I don't have no relevant context right now, I think it would be best for you—having just opened the PR—to see it through to completion. |
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
Extracted from RustPython#6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations.
* Implement _collections.OrderedDict Extracted from #6799: native OrderedDict as a dict subclass, iterator mutation tracking, and mapping-view set operations. * Add OrderedDict, warnings source lines, and socket sendmsg Implement _collections.OrderedDict as a dict subclass with a linked list of insertion-order nodes. Pack struct F/D as native float/double complex pairs, and report unexpected __replace__ field names as a list repr. Register encodings.latin_1 at startup. Reject NUL in input() prompts. Copy non-exact type dicts in mapping order. Fetch warning source lines through _bless_my_loader and unicode splitlines. Keep the last warnings.filters list after deletion. Snapshot sendmsg sequences before converting buffers, parse ancillary ints with __index__, and dispatch AF_CAN by protocol. Store sys.trace and sys.profile on each ThreadSlot so _settraceallthreads/_setprofileallthreads are visible to sys.gettrace/getprofile on other threads. Use <frozen importlib._bootstrap> as frozen importlib co_filename. Keep HEAPTYPE socket objects GC-tracked. Assisted-by: Grok:grok-4.6 * Load marshal via readinto and dump sets in dumps order marshal.load fills a scratch buffer with readinto on a contiguous writable memoryview, and rejects a returned length other than the requested size. set and frozenset dumps write elements in sorted(v, key=marshal.dumps) order. Assisted-by: Grok:grok-4.6 * Add classmethod_descriptor and ABC IS_ABSTRACT flags Give METH_CLASS methods a distinct classmethod_descriptor type. Store Py_TPFLAGS_IS_ABSTRACT from __abstractmethods__ and look up that attribute only in the type's own dict. Expose defaultdict.default_factory as a member descriptor. Inherit bool's unused number slots from int. Mark set and frozenset __contains__ as METH_COEXIST. Parse classmethod, staticmethod, object.__new__, and heap type text signatures. Register interactive source in linecache. Assisted-by: Grok:grok-4.6 * address review: odict reuse, descr call, new wrapper Reuse odict node slots and walk the live list in next_after. Require both | operands to be dicts. Drop the odict iterator on GC clear. Bind classmethod descriptors through descr_get and update IS_ABSTRACT under the type lock. Give odict keys and items sq_contains. Walk tp_new_wrapper past new_wrapper so HEAPTYPE socket subclasses can call socket.__new__. Split FreeBSD Bluetooth protocol constants from Linux values. Assisted-by: Grok:grok-4.6 * Represent chflags bits with bitflagset Assisted-by: Grok:grok-4.6 * Represent access and mode bits with bitflagset Assisted-by: Grok:grok-4.6 * Continue unfinished REPL suites as incomplete input Assisted-by: Grok:grok-4.6 * Add pickle and os.stat inspect signatures Give _pickle.Pickler the clinic constructor text signature and accept fix_imports and buffer_callback as positional-or-keyword. Allow #[pyfunction(text_signature)] and use it so os.stat reports (path, *, dir_fd=None, follow_symlinks=True). Uncomment import _pickle and drop the pickle inspect expectedFailures. Assisted-by: Grok:grok-4.6 * Add Unpickler, dump/load, and lstat signatures Give _pickle Unpickler, dump, dumps, load, and loads clinic text signatures, and os.lstat (path, *, dir_fd=None). Assisted-by: Grok:grok-4.6 * Complete OrderedDict with insertion-order links Move the native OrderedDict into ordered_dict.rs and track order with a linked list of nodes, keeping mapping-view set operations. Assisted-by: Grok:grok-4.6 * address CI: stat casts, HCI_DATA_DIR, passing xfails Compare stat permission bits as Mode so Linux clippy does not flag a u32-to-u32 cast. Export HCI_DATA_DIR with the Bluetooth socket option values. Drop expectedFailure from tests that now pass. Assisted-by: Grok:grok-4.6 * Fix wasm teardown deadlock and bluetooth constants Assisted-by: Grok:grok-4.6 * Clear process-wide eval breaker bits in STW test Assisted-by: Grok:grok-4.6 * Drop exclusive-held panic that tripped wasm clippy Assisted-by: Grok:grok-4.6 * Fix OrderedDict contains and export Windows BDADDR Assisted-by: Grok:grok-4.6 * Add cmp_to_key and hash-once LRU cache _functools.cmp_to_key now returns KeyWrapper. LRU lookups store the key hash on _lru_list_elem so __hash__ is not called again on hits or eviction. Assisted-by: Grok:grok-4.6 * Allow subclass keywords on list, tuple, and float list.__init__ rejects keywords only when tp_new is still list's. tuple/float.__new__ reject them only when tp_init is still the base's. Assisted-by: Grok:grok-4.6 * Fix CI lint, test re-export, and structseq members Drop the duplicate clear_eval_breaker_for_test re-export. Format structseq imports. Expose struct sequence fields as readonly members so assignment raises "readonly attribute". Assisted-by: Grok:grok-4.6 * Allow subclass keywords on itertools and filter Positional-only constructors ignore extra keywords when a subclass has replaced tp_init, matching list/tuple/float. Assisted-by: Grok:grok-4.6 * Remove text_signature derive parameter Drop the string override on #[pyfunction] and #[pyclass]. Signatures are generated from the Rust parameter list only. Restore inspect expectedFailures that depended on the override. Assisted-by: Grok:grok-4.6 * Rename set contains_method to __contains__ Keep a borrowed contains helper for slots and C-API. The coexist pymethod is named __contains__. Assisted-by: Grok:grok-4.6 * Use MonitoringEvent instead of EVENT_* aliases Drop the unused MonitoringEvents bitflags and the EVENT_PY_START style mask constants. Call sites use the enum and .mask(). Assisted-by: Grok:grok-4.6 * Store warnings filters as PyListRef The list already serializes its elements. Drop the extra mutex around the cached list pointer. Assisted-by: Grok:grok-4.6 * Re-export clear_eval_breaker_for_test after rebase Keep the STW test helper visible without bringing back stop_bit_set. Assisted-by: Grok:grok-4.6 * Fix groupby reentrancy and islice arguments Give _grouper its own tgtkey and take currvalue after the key comparison. Accept __index__ on islice bounds, reject step 0, and drain the source up to stop. Assisted-by: Grok:grok-4.6 * SETREF warnings filters, onceregistry, and defaultaction Keep the last list, dict, or str after the module attributes are deleted by swapping the interpreter cache pointer. Do not store a None fallback for _warnings_context. Assisted-by: Grok:grok-4.6 * Iterate OrderedDict inner dict via next_entry &PyDict is not an iterator after the borrowed-ref signature change. Assisted-by: Grok:grok-4.6 * Remove expectedFailure from testBluetoothConstants Linux now exports BTPROTO_HCI and the rest of the set. Assisted-by: Grok:grok-4.6 * Borrow get_filter arguments as PyObject Match the warn_explicit call site that passes borrowed handles after the internal-helper borrow change. Assisted-by: Grok:grok-4.6 * Fix bool slots and SemHandle safety docs Leave unused bool number slots unset so inspect reports __add__ on int. Document SemHandle::from_raw safety. Assisted-by: Grok:grok-4.6 * Keep sendmsg errors and drop duplicate linecache Replace sendmsg iterable TypeError only. Register REPL source in linecache once per compiled input. Assisted-by: Grok:grok-4.6 * Nest REPL parse or-patterns for clippy Assisted-by: Grok:grok-4.6 * Mark pydoc os.stat signature test expectedFailure Assisted-by: Grok:grok-4.6 --------- Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
This pull request will resolve some parts of #3418. I need to review these code again 🔨