Skip to content

Extract BinaryHeap from DataStructures.jl v1.0.0 - #1

Merged
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:extract-binary-heaps
Apr 12, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:extract-binary-heaps

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

  • Extracts BinaryHeap, BinaryMinHeap, BinaryMaxHeap, and FasterForward/FasterReverse orderings from DataStructures.jl into a standalone, lightweight package
  • Also includes array-based heap operations (heapify!, heappush!, heappop!, isheap) and utility functions (nlargest, nsmallest, extract_all!)
  • Tests extracted from DataStructures.jl test suite (493 tests passing)

Motivation

Loading DataStructures.jl causes 6 method invalidation trees from components completely unrelated to heap functionality (OrderedCollections sort!/get!/getkey, Accumulators merge!, SortedContainers IteratorSize/merge). BinaryHeaps.jl causes zero invalidations.

DataStructures.jl:
  Invalidation trees: 6
    Tree 1: kwcall(...sort!...LittleDict...) @ OrderedCollections
    Tree 2: get!(h::OrderedDict...) @ OrderedCollections
    Tree 3: merge!(ct::Accumulator...) @ DataStructures
    Tree 4: getkey(dd::LittleDict...) @ OrderedCollections
    Tree 5: Base.IteratorSize(...SortedDict/SortedMultiDict/SortedSet...) @ DataStructures
    Tree 6: merge(m::SortedMultiDict...) @ DataStructures

BinaryHeaps.jl:
  Invalidation trees: 0

This is a drop-in replacement for DataStructures.BinaryHeap usage in packages like OrdinaryDiffEq.jl, which only uses BinaryHeap{T}(FasterForward()), BinaryMinHeap, push!, pop!, first, isempty, empty!, and sizehint!.

Attribution

Original code Copyright (c) 2013 Dahua Lin, MIT License.

Test plan

  • All 493 tests pass (extracted from DataStructures.jl test suite)
  • Invalidation comparison script confirms 0 invalidation trees
  • CI passes

🤖 Generated with Claude Code

Provides BinaryHeap, BinaryMinHeap, BinaryMaxHeap, and FasterForward/
FasterReverse orderings extracted from DataStructures.jl to eliminate
method invalidations caused by loading the full DataStructures package.

DataStructures.jl causes 6 invalidation trees (from OrderedCollections,
Accumulators, SortedContainers) that are completely unrelated to heap
functionality. BinaryHeaps.jl causes zero invalidations.

Tests are extracted from DataStructures.jl test suite (493 tests pass).

Original code Copyright (c) 2013 Dahua Lin, MIT License.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to 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