From def1e48dce368b685f65d9138832e4d1036c2e30 Mon Sep 17 00:00:00 2001 From: MilesCranmerBot Date: Tue, 29 Sep 2026 00:22:31 +0000 Subject: [PATCH] Remove > and >= methods on Py to reduce invalidations Base only defines > and >= as generic fallbacks (y < x, y <= x), so adding these methods invalidated thousands of method instances elsewhere (6830 -> 2532 unique instances when loading PythonCall + SymbolicRegression on Julia 1.12). Dropping them routes x > y through Base's fallback to the existing < and <= methods, so results and the Py return type are unchanged. The only behavior change is that Python now tries y.__lt__ before x.__gt__. pygt and pyge remain exported and are still used by the @py macro. Refs #828 Co-authored-by: Miles Cranmer --- src/Core/Py.jl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Core/Py.jl b/src/Core/Py.jl index 0705bded..fd95e577 100644 --- a/src/Core/Py.jl +++ b/src/Core/Py.jl @@ -361,8 +361,6 @@ Base.:(==)(x::Py, y::Py) = pyeq(x, y) Base.:(!=)(x::Py, y::Py) = pyne(x, y) Base.:(<=)(x::Py, y::Py) = pyle(x, y) Base.:(<)(x::Py, y::Py) = pylt(x, y) -Base.:(>=)(x::Py, y::Py) = pyge(x, y) -Base.:(>)(x::Py, y::Py) = pygt(x, y) Base.isless(x::Py, y::Py) = pylt(Bool, x, y) Base.isequal(x::Py, y::Py) = pyeq(Bool, x, y) @@ -371,8 +369,6 @@ Base.:(==)(x::Py, y::Number) = pyeq(x, y) Base.:(!=)(x::Py, y::Number) = pyne(x, y) Base.:(<=)(x::Py, y::Number) = pyle(x, y) Base.:(<)(x::Py, y::Number) = pylt(x, y) -Base.:(>=)(x::Py, y::Number) = pyge(x, y) -Base.:(>)(x::Py, y::Number) = pygt(x, y) Base.isless(x::Py, y::Number) = pylt(Bool, x, y) Base.isequal(x::Py, y::Number) = pyeq(Bool, x, y) @@ -380,8 +376,6 @@ Base.:(==)(x::Number, y::Py) = pyeq(x, y) Base.:(!=)(x::Number, y::Py) = pyne(x, y) Base.:(<=)(x::Number, y::Py) = pyle(x, y) Base.:(<)(x::Number, y::Py) = pylt(x, y) -Base.:(>=)(x::Number, y::Py) = pyge(x, y) -Base.:(>)(x::Number, y::Py) = pygt(x, y) Base.isless(x::Number, y::Py) = pylt(Bool, x, y) Base.isequal(x::Number, y::Py) = pyeq(Bool, x, y)