Skip to content

adjust dict reverse iterator next to new dict entries structure#2915

Merged
youknowone merged 2 commits into
RustPython:masterfrom
eldpswp99:adjust-dict-reverse-iterator-to-new-dict-entries
Aug 21, 2021
Merged

adjust dict reverse iterator next to new dict entries structure#2915
youknowone merged 2 commits into
RustPython:masterfrom
eldpswp99:adjust-dict-reverse-iterator-to-new-dict-entries

Conversation

@eldpswp99

@eldpswp99 eldpswp99 commented Aug 19, 2021

Copy link
Copy Markdown
Contributor

dict entries was changed due to remain order even when delete any element. #2902

in this PR, i only adjust dict reverse iterator next function to this new dict entries structure.

however, there remains some issue about detecting the change while iteration.
before, the size change was equivalent to the change of the dictionary entries, so it was easy to detect it
however, making deletion not to erase entries, and insertion occurs on next_new_entry_idx, it is hard to detect change during iteration.
all iterators with dict may have this issue.

Comment thread vm/src/builtins/dict.rs Outdated
Comment on lines +785 to +788
let mut position = zelf.position.load();
match zelf.dict.entries.next_entry_reversed(&mut position) {
Some((key, value)) => {
zelf.position.store(position);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch_add was atomic operation, but the combination of load and store is not. Can we express this as consecutive fetch_add?

@eldpswp99 eldpswp99 Aug 21, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i fixed this with only using fetch_add in next_entry_reversed. there exists same problem in dict iterator, i would fix it in another PR since this PR is about reverse iterator.

@eldpswp99 eldpswp99 requested a review from youknowone August 21, 2021 09:58
@youknowone youknowone merged commit 48437d0 into RustPython:master Aug 21, 2021
@youknowone youknowone added the z-ca-2021 Tag to track contrubution-academy 2021 label Oct 16, 2021
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.

2 participants