The Wayback Machine - https://web.archive.org/web/20260127201522/https://github.com/RustPython/RustPython/pull/1072
Skip to content

Conversation

@sanxiyn
Copy link
Contributor

@sanxiyn sanxiyn commented Jun 29, 2019

cc #578

@windelbouwman windelbouwman requested a review from adrian17 June 30, 2019 18:14
@windelbouwman
Copy link
Contributor

@sanxiyn I'm not that familiar with sorting. @adrian17 could you have a look at this change?

@@ -0,0 +1,11 @@
class Stable:
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have tests for sorting in tests/snippets/list.py - would be nice if they were in one place - either there or in the new file.

let result = vm._lt(keys[i].clone(), keys[len - 1].clone())?;
let boolval = objbool::boolval(vm, result)?;
if boolval {
let eq = vm._eq(keys[i].clone(), keys[len - 1].clone())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty sure CPython doesn't use __eq__, so this implementation may fail for classes that do stuff like

def __eq__(self, other): raise NotImplementedError

CPython's TimSort only uses __lt__ (and object identity comparisons)

@coolreader18
Copy link
Member

@sanxiyn would you be interested in fixing this up a bit so we can merge? It looks good and I think the code this touches hasn't changed that much in the ~5 months since this was opened (there aren't any merge conflicts, at least).

This was referenced Aug 26, 2020
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.

4 participants