Skip to content

Remove methods like ==(::Py, ::Number) and +(::Number, ::Py) #703

Description

@cjdoris

These are handy but they break the general model that a Python int is not a Julia Integer etc.

For example we currently have Py(3) == 3 but hash(Py(3)) != hash(3), which breaks a Julia invariant.

I suspect it might lead to method invalidations too but I don't know.

Activity

  1. added this to the v1 milestone on Oct 23, 2025
  2. self-assigned this
    on Oct 23, 2025
  3. added theissue type on Oct 23, 2025
  4. changed the issue type fromtoon Oct 23, 2025
  5. cjdoris commented on Oct 27, 2025

    @cjdoris
    MemberAuthor

    @codex can you make a pr to implement this

  6. chatgpt-codex-connector commented on Oct 27, 2025

    @chatgpt-codex-connector

    Summary

    • Restricted comparison and arithmetic overloads to Py arguments so that mixed Py/Number operator methods are no longer provided by default. src/Core/Py.jlL365-L400
    • Updated the arithmetic and logic documentation to clarify that Julia operators delegate to Python only when all operands are Py values and to recommend using the explicit py* helpers for mixed inputs. docs/src/pythoncall-reference.mdL102-L149
    • Revised broadcast tests to operate purely on Python objects and added assertions that Julia number interop now raises MethodError, ensuring the new behaviour is covered. test/Core.jlL786-L803

    Testing

    • ⚠️ julia --project -e 'using Pkg; Pkg.test()' (fails because julia executable is unavailable in the environment)

    View task →

  7. cjdoris commented on Nov 2, 2025

    @cjdoris
    MemberAuthor

    Closed by #709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions