Skip to content

Invalid "python equivalent" in PyObject_RichCompareBool() #113445

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

Closed
skirpichev opened this issue Dec 24, 2023 · 2 comments
Closed

Invalid "python equivalent" in PyObject_RichCompareBool() #113445

skirpichev opened this issue Dec 24, 2023 · 2 comments
Labels
docs Documentation in the Doc dir

Comments

@skirpichev
Copy link
Contributor

skirpichev commented Dec 24, 2023

It should be bool(o1 op o2) instead. Or (better?) the sentence "This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid." could be removed, as the note below shows there is no simple equivalent python expression:

.. note::
If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool`
will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`.

Linked PRs

@skirpichev skirpichev added the docs Documentation in the Doc dir label Dec 24, 2023
@Lilneo786
Copy link

import ctypes

# Create a Python object
obj = [1, 2, 3]

# Check if the object is equal to itself
result_eq = obj == obj
print("Equal:", result_eq)  # Output: Equal: True

# Check if the object is not equal to itself
result_ne = obj != obj
print("Not Equal:", result_ne)  # Output: Not Equal: False

@skirpichev
Copy link
Contributor Author

@Lilneo786, not sure I get your point, could you elaborate, please?

skirpichev added a commit to skirpichev/cpython that referenced this issue Jan 10, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 27, 2024
(cherry picked from commit 926881d)

Co-authored-by: Sergey B Kirpichev <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 27, 2024
(cherry picked from commit 926881d)

Co-authored-by: Sergey B Kirpichev <[email protected]>
serhiy-storchaka pushed a commit that referenced this issue Jan 27, 2024
serhiy-storchaka pushed a commit that referenced this issue Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants