Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python dicts are not trees #35

Closed
wants to merge 1 commit into from

Conversation

robinovitch61
Copy link

AFAIK python dicts are not trees, they are hash tables with a deterministic but non-linear probing for resolving collisions.

See here for details: https://just-taking-a-ride.com/inside_python_dict/chapter4.html

AFAIK python dicts are not trees, they are hash tables with a deterministic but non-linear probing for resolving collisions.

See here for details: https://just-taking-a-ride.com/inside_python_dict/chapter4.html
@vkarpov15
Copy link
Owner

When you have nested dicts, you can think of them as trees.

// The metaphor here is that `dict` represents a tree with 3 nodes `nested`, `answer`, and `otherProp`
dict = {"nested":{"answer":42},"otherProp":"test"}

The implementation under the hood isn't particularly relevant here - I'd guess that JS and Ruby also implement their object structures as hash maps internally as well.

@vkarpov15 vkarpov15 closed this Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants