Opened 6 years ago

Closed 6 years ago

#21128 closed enhancement (fixed)

Improve support for comparisons in plain Python modules

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-7.3
Component: coercion Keywords:
Cc: chapoton, vdelecroix Merged in:
Authors: Jeroen Demeyer Reviewers: Vincent Delecroix, Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 2585c4f (Commits, GitHub, GitLab) Commit: 2585c4f4b273bc82c0c60683540e42417dd5f56c
Dependencies: Stopgaps:

Status badges

Description

This is meant to improve the way how plain Python modules can use _richcmp_.

We need access to the CPython function PyObject_RichCompare() which —as far as I know— is not exposed by Python. So we add a Python interface to PyObject_RichCompare() called richcmp().

Change History (10)

comment:1 Changed 6 years ago by jdemeyer

  • Branch set to u/jdemeyer/ticket/21128

comment:2 Changed 6 years ago by jdemeyer

  • Commit set to f9db8433c07ec7c3c352e6660f0f314a0a0d35a5
  • Status changed from new to needs_review

New commits:

f9db843Improve support for comparisons in plain Python modules

comment:3 follow-ups: Changed 6 years ago by dmuthiah

  • Reviewers set to Vincent Delecroix

The function py_rich_to_bool had some documentation that richcmp lacks. And making py_rich_to_bool a deprecated alias of richcmp would be good.

comment:4 in reply to: ↑ 3 Changed 6 years ago by jdemeyer

Replying to dmuthiah:

And making py_rich_to_bool a deprecated alias of richcmp would be good.

The function py_rich_to_bool is not a public function, so I don't think we should do the trouble of deprecating it. But if you insist, I will do that.

comment:5 Changed 6 years ago by vdelecroix

It is not clear to me what is a public function. py_rich_to_bool is exactly the kind of function that is helpful for external Sage modules. Hence a deprecation seems reasonable to me.

comment:6 in reply to: ↑ 3 Changed 6 years ago by jdemeyer

Replying to dmuthiah:

The function py_rich_to_bool had some documentation that richcmp lacks. And making py_rich_to_bool a deprecated alias of richcmp would be good.

py_rich_to_bool is replaced by the existing function rich_to_bool and no documentation is lost. The function richcmp() is a new function analogous to cmp().

comment:7 Changed 6 years ago by chapoton

Looks good.

Nevertheless, I would also prefer a deprecation for py_rich_to_bool.

comment:8 Changed 6 years ago by git

  • Commit changed from f9db8433c07ec7c3c352e6660f0f314a0a0d35a5 to 2585c4f4b273bc82c0c60683540e42417dd5f56c

Branch pushed to git repo; I updated commit sha1. New commits:

2585c4fMake py_rich_to_bool a deprecated alias for rich_to_bool

comment:9 Changed 6 years ago by vdelecroix

  • Reviewers changed from Vincent Delecroix to Vincent Delecroix, Frédéric Chapoton
  • Status changed from needs_review to positive_review

comment:10 Changed 6 years ago by vbraun

  • Branch changed from u/jdemeyer/ticket/21128 to 2585c4f4b273bc82c0c60683540e42417dd5f56c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.