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

Implement collections.defaultdict #874

Merged
merged 16 commits into from Aug 7, 2018

Conversation

Projects
None yet
2 participants
@BPYap
Contributor

BPYap commented Jul 25, 2018

No description provided.

@BPYap BPYap changed the title from Implement collections.defaultdict [WIP] to Implement collections.defaultdict Jul 26, 2018

@freakboy3742

As discussed on our call - it would be preferable to make __missing__ a method that exists on org.python.types.Dict, but not exposed as a org.python.Method, so you can use classical OO patterns in __getitem__

@BPYap

This comment has been minimized.

Contributor

BPYap commented Jul 27, 2018

@freakboy3742 Sorry my brain got short-circuited just now 😅. Actually the reason I make a private __getitem__ on org.python.types.Dict is to preserve dict behavior on defaultdict. You see, other than __getitem__, defaultdict has exactly the same behavior as dict when other methods are call.

e.g. defaultdict.get(x) should return None (same as dict) when x is not a key instead of invoking the default_factory for missing value.
However the implementation of get(x) in voc calls __getitem__(x) which indirectly calls __missing__(x), causing defaultdict to return default_factory value instead of None, hence the need of another 'internal use' __getitem__ without calls to __missing__.

BPYap added some commits Jul 30, 2018

@freakboy3742

👍 Looks good!

@freakboy3742 freakboy3742 merged commit 2b781d1 into pybee:master Aug 7, 2018

5 checks passed

beekeeper:0/beefore:javacheckstyle Java lint checks passed.
Details
beekeeper:0/beefore:pycodestyle Python lint checks passed.
Details
beekeeper:1/smoke-test Smoke build (Python 3.4) passed.
Details
beekeeper:2/full-test:py3.5 Python 3.5 tests passed.
Details
beekeeper:2/full-test:py3.6 Python 3.6 tests passed.
Details

@BPYap BPYap deleted the BPYap:collections-module-defaultdict branch Aug 8, 2018

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