Skip to content

make dict remain order after delete#2902

Merged
coolreader18 merged 6 commits into
RustPython:masterfrom
eldpswp99:dict-remain-order-after-delete
Aug 17, 2021
Merged

make dict remain order after delete#2902
coolreader18 merged 6 commits into
RustPython:masterfrom
eldpswp99:dict-remain-order-after-delete

Conversation

@eldpswp99

@eldpswp99 eldpswp99 commented Aug 17, 2021

Copy link
Copy Markdown
Contributor

closes #2550

before:

  • dict is insertion order in CPython, but in RustPython the order was broken when deletion is occured

after:

  • it follows the CPython way. when it is deleted, make the entry to None, and remove this None only if resize occurs.

  • added nentries to optimize popitem. it is equal to the index for next insertion (= last valid entry index + 1)

@eldpswp99 eldpswp99 changed the title Dict remain order after delete make dict remain order after delete Aug 17, 2021
@DimitrisJim

Copy link
Copy Markdown
Member

Fix the passing test in test_ordered_dict (test_del) and I'll re-run the ci, not sure why the ubuntu check isn't finishing.

@eldpswp99

eldpswp99 commented Aug 17, 2021

Copy link
Copy Markdown
Contributor Author

@DimitrisJim I think there might be an infinite loop in the ubuntu test.
When i working on this commit, there was an infinite loop when implementing pop_back. when i have a inner with write lock and call lookup with lock None. but i fixed with making inner to read lock and passing it to lookup. the loop removed. but i'm not sure why the ci doesn't finished in ubuntu particularly.

@DimitrisJim

Copy link
Copy Markdown
Member

It's weird that it only occurs there. I'll try and look into it.

Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
@eldpswp99 eldpswp99 force-pushed the dict-remain-order-after-delete branch from c80bcdf to abdbca0 Compare August 17, 2021 17:16
Comment thread vm/src/dictdatatype.rs Outdated
Comment thread vm/src/dictdatatype.rs Outdated
@eldpswp99 eldpswp99 force-pushed the dict-remain-order-after-delete branch from abdbca0 to 564eb29 Compare August 17, 2021 17:29
@coolreader18 coolreader18 merged commit e277acc into RustPython:master Aug 17, 2021
@eldpswp99

Copy link
Copy Markdown
Contributor Author

Thank you for all the reviews...!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

z-ca-2021 Tag to track contrubution-academy 2021

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants