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

Add `sorted` and `list.sort` · Pull Request #81 · go-python/gpython

Repository navigation

Add sorted and list.sort - #81


Merged
corona10 merged 10 commits into master from unknown repository Sep 29, 2019
Merged

Add sorted and list.sort #81 corona10 merged 10 commits into master from unknown repository

Conversation

ghost commented Sep 15, 2019



Copy link Copy Markdown

No description provided.

Tim-St added 4 commits September 10, 2019 19:59 Add sorted and list.sort ffb374f
Mostly finished, needs some argument parsing changes.
Unpacking of args works now for sorted and list.sort 7cc1d0b add tests d31767d new try cf32df7 corona10 requested a review from ncw September 15, 2019 17:16

codecov-io commented Sep 15, 2019 · edited Loading



Copy link Copy Markdown

Codecov Report

Merging #81 into master will increase coverage by 0.7%.
The diff coverage is 67.96%.

@@            Coverage Diff            @@
##           master      #81     +/-   ##
=========================================
+ Coverage   68.65%   69.36%   +0.7%     
=========================================
  Files          59       60      +1     
  Lines       10525    10778    +253     
=========================================
+ Hits         7226     7476    +250     
+ Misses       2790     2775     -15     
- Partials      509      527     +18
Impacted Files Coverage Δ
builtin/builtin.go 80.17% <100%> (+0.49%) ⬆️
py/list.go 46.71% <62.92%> (+11.58%) ⬆️
repl/repl.go 100% <0%> (ø) ⬆️
py/range_repr110.go 70% <0%> (ø)
py/type.go 52.36% <0%> (+0.81%) ⬆️
py/internal.go 41.78% <0%> (+0.91%) ⬆️
py/sequence.go 54.83% <0%> (+2.15%) ⬆️
py/method.go 61.32% <0%> (+2.83%) ⬆️
py/float.go 35.23% <0%> (+2.85%) ⬆️
... and 4 more

Continue to review full report at Codecov .

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov . Last update eb115a9...5f7a289 . Read the comment docs .

corona10 requested changes Sep 28, 2019
View reviewed changes

corona10 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 .

@Tim-St Hi, Thanks for the contribution.
I know implementing sort for python interpreter(tim sort) is very hard.
Would you like to add the test about the list for your change?
The test should be run at here.
https://github.com/go-python/gpython/blob/master/py/tests/list.py
Might be coverage will be increased.

ghost commented Sep 28, 2019



Copy link Copy Markdown
Author

@corona10 Ok, I will add some test cases.
There is a PR at golang that implements Block Sort , which will improve the stable sort, once it's merged. Timsort isn't wanted in Go because it uses O(n) space currently.

corona10 commented Sep 28, 2019



Copy link Copy Markdown
Collaborator

@Tim-St Thanks for the information!

Tim-St added 2 commits September 28, 2019 11:27 Add tests for list.sort f411862 Update list.py a432c54

corona10 commented Sep 28, 2019



Copy link Copy Markdown
Collaborator

@ncw @sbinet Can you take a look at this PR?

ghost commented Sep 28, 2019



Copy link Copy Markdown
Author

I will add one more thing.

a = [1,3,2]
assert list.sort(a) is None
assert a == [1, 2, 3]

should work. Currently this syntax doesn't work for list.append etc too.

Tim-St added 3 commits September 28, 2019 14:07 support list.sort([], **kwargs) 6b84462 Update list.go af6732d better NoneType comparison c8d35a9 ncw reviewed Sep 28, 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 .

This looks like excellent work :-)

If we could get the coverage of the patch up to above the threshold that would be perfect!

I didn't see anything which I thought needed changing :-)

ghost commented Sep 28, 2019



Copy link Copy Markdown
Author

@ncw Thanks! I'd like to change it to get a higher score, but I don't understand how "codecov" measures the results, and there are no hints on the page which parts should be changed :\

ncw commented Sep 28, 2019



Copy link Copy Markdown
Collaborator

@ncw Thanks! I'd like to change it to get a higher score, but I don't understand how "codecov" measures the results, and there are no hints on the page which parts should be changed :\

:-)

The output is a bit cryptic

The easiest way to improve the coverage is to use the go coverage tools locally to see the bits which haven't been covered in the code you've added. Cover those and the coveralls score will increase!

put tests for sorted in builtin.py 5f7a289

ghost commented Sep 29, 2019



Copy link Copy Markdown
Author

Hm, when I run this cover tool, most of the code in list.go is marked red, not only my code. I don't know how to improve this, maybe someone can show me how to get this right.

corona10 commented Sep 29, 2019



Copy link Copy Markdown
Collaborator

This looks like excellent work :-)
If we could get the coverage of the patch up to above the threshold that would be perfect!
I didn't see anything which I thought needed changing :-

@Tim-St cc @ncw
If there no issue with the current code without code coverage.
We can go to merge it.

corona10 merged commit af17d7d into go-python : master Sep 29, 2019

corona10 commented Sep 29, 2019



Copy link Copy Markdown
Collaborator

@Tim-St
Thanks for your contribution!

benniekv pushed a commit to benniekv/gpython that referenced this pull request Nov 19, 2026 Add sorted and list.sort (go-python#81) 1ec6dfb
* Add `sorted` and `list.sort`

Mostly finished, needs some argument parsing changes.

* Unpacking of args works now for `sorted` and `list.sort`

* add tests

* new try

* Add tests for `list.sort`

* Update list.py

* support `list.sort([], **kwargs)`

* Update list.go

* better NoneType comparison

* put tests for `sorted` in `builtin.py`
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

4 participants