← Winnitude! Search  ·  Reader Mode (2261 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 35 LINKS

[WIP] Implement dict to receive Object as key by HyeockJinKim · Pull Request #119 · go-python/gpython

Repository navigation

[WIP] Implement dict to receive Object as key - #119


Open
HyeockJinKim wants to merge 1 commit into go-python:main from HyeockJinKim:issue118
Open

[WIP] Implement dict to receive Object as key #119 HyeockJinKim wants to merge 1 commit into go-python:main from HyeockJinKim:issue118

Conversation

HyeockJinKim commented Oct 19, 2019



Copy link Copy Markdown
Contributor

Implement dict struct that takes Object as key
store key and value in array together so that dict is ordered

Issue #118

Implement dict to receive Object as key 9e2f6ab
Implement dict struct that takes Object as key
store key and value in array together so that dict is ordered

Issue go-python#118

codecov-io commented Oct 19, 2019 · edited by codecov
Bot
Loading



Copy link Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.20%. Comparing base (0c23b14 ) to head (9e2f6ab ).
⚠️ Report is 109 commits behind head on main.

Files with missing lines Patch % Lines
py/dict.go 0.00% 106 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
- Coverage   72.85%   72.20%   -0.66%     
==========================================
  Files          60       60              
  Lines       11949    12057     +108     
==========================================
  Hits         8706     8706              
- Misses       2709     2815     +106     
- Partials      534      536       +2     

☔ View full report in Codecov by Harness .
📢 Have feedback on the report? Share it here .

🚀 New features to boost your workflow:
  • ❄️ Test Analytics : Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis : Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

HyeockJinKim commented Oct 19, 2019



Copy link Copy Markdown
Contributor

Author

Since Hash is not implemented properly in gpython, I'm going to implement a dict that takes an Object as a key first.

So, even if an object representing the same value comes in as key, the value is not found correctly.

This can break the test code, so instead of getting rid of StringDict, I will fully implement Dict and replace StringDict with Dict.

ncw reviewed Oct 21, 2019
View reviewed changes

ncw left a comment



Copy link Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I put some notes inline...

Making a Dict is quite a dififcult thing to do (probably why I didn't do it originally!)

Perhaps the thing to do to start with would be to make one with a simple internal structure which is just

type keyValue {
    key Object
    value Object
}

type Dict struct {
    kvs []keyValue
}

And make that work. Yes it won't be very efficient if there are lots of keys, but it should enable us to get the interface right, then we can work on optimizing it.

I note that in go1.14 the go team will expose the internal hashing function which would make implementing this much easier.

Comment thread py/dict.go
type StringDict map[string]Object

type Dict struct {
keys map[Object]int
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

4 participants