Skip to content

prevent adding methods to the functions > and >= - #771

Merged
devmotion merged 2 commits into
JuliaDiff:masterfrom
nsajko:prevent_adding_methods_fix
Sep 8, 2025
Merged

prevent adding methods to the functions > and >=#771
devmotion merged 2 commits into
JuliaDiff:masterfrom
nsajko:prevent_adding_methods_fix

Conversation

@nsajko

Copy link
Copy Markdown
Contributor

As documented, the intended way to implement > is to add a method to <. Similarly with >=. A package should never add a method to either > or >=.

As documented, the intended way to implement `>` is to add a method to
`<`. Similarly with `>=`. A package should never add a method to either
`>` or `>=`.
@codecov

codecovBot commented Sep 8, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.82%. Comparing base (7decc58) to head (15f0d80).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #771 +/- ##
=======================================
Coverage 89.82% 89.82% =======================================
Files 11 11 Lines 1032 1032 =======================================
Hits 927 927 Misses 105 105 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nsajko
nsajko marked this pull request as ready for review September 8, 2025 02:29

@devmotiondevmotion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch! The reason for these unnecessary definitions is that up until recently x < y for Dual numbers was not equivalent with !(x >= y). I fixed this in #695 but apparently did not clean up the code.

Comment threadsrc/dual.jl Outdated
# BINARY_PREDICATES = Symbol[:isequal, :isless, :<, :>, :(==), :(!=), :(<=), :(>=)]
# Not a minimal set, as Base defines some in terms of others.
for pred in [:<, :>]
for pred in [:<]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With only a single element in pred, the loop and the @eval below are not needed anymore. Can you remove them?

@nsajko

Copy link
Copy Markdown
ContributorAuthor

This change decreases the unique invalidation count upon using ForwardDiff from 1504 to 784.

Instructions to reproduce this result:

  • Do @snoop_invalidations using ForwardDiff before loading any other package except for SnoopCompileCore. Not even the REPL or Pkg may be loaded before ForwardDiff, because they load StyledStrings, which does some piracy, causing invalidation, thus affecting the result.

  • Use nightly Julia v1.13, commit JuliaLang/julia@865b8be.

Data on each invalidation:

@devmotion
devmotion merged commit 42e0aa6 into JuliaDiff:masterSep 8, 2025
12 checks passed
@nsajko
nsajko deleted the prevent_adding_methods_fix branch September 8, 2025 17:12
@nsajkonsajko mentioned this pull request Sep 9, 2025
Merged
devmotion pushed a commit that referenced this pull request Sep 9, 2025
Release PRs #771 and #751.
Specifically I want a release because of the former, to cut down on
sysimage invalidation when loading ForwardDiff.
Sign up for freeto 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.

2 participants

@nsajko@devmotion