Skip to content

Add defaultdict to collections; add pprint.py #1134

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

Merged
merged 2 commits into from
Jul 11, 2019

Conversation

coolreader18
Copy link
Member

Ok, so I did it in Python because I encountered a ton of broken/fragile class machinery when I tried to do it in Rust: subclassing a built-in class but also being a PyValue itself weirdness, inconsistency with CPython in how __new__ vs __init__ works (it was calling __new__ with arguments intended for __init__, and I still had to work around that in Python), and the final straw, __missing__ not being detected from dict.__getitem__, while __missing__ did work in Python. In any case defaultdict being a native class is mostly just an implementation detail, and there's really no reason why it can't be implemented in Python. We can look at all that at some point later, but we're really close to unittest and I'm focusing on that at the moment.

@windelbouwman windelbouwman merged commit 3c9045d into master Jul 11, 2019
@windelbouwman
Copy link
Contributor

windelbouwman commented Jul 11, 2019

Nice, I was hitting this before as well! Nice job! We should think of improving the broken / fragile stuff. Could you make an issue for this / the seperate topics?

@coolreader18 coolreader18 deleted the coolreader18/collections-defaultdict branch July 11, 2019 05:30
@coolreader18
Copy link
Member Author

Sounds good, I'll do that in the morning.

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