[print] Simplify custom print-method detection#419
Draft
bbatsov wants to merge 1 commit into
Draft
Conversation
Drop the per-class cache (deftype + ConcurrentHashMap + generation tracking) in favor of comparing the live get-method result against the generic collection registrations - MultiFn's own dispatch cache does the heavy lifting, and staleness handling disappears because every lookup sees the current registrations. Add *honor-print-method* so consumers can turn the whole feature off per context.
bbatsov
force-pushed
the
simplify-print-method-detection
branch
from
July 15, 2026 16:24
e7ca9b9 to
a2ef1e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following up on the concern that #415 brought too much complexity: this strips the mechanism down to its minimum while keeping the behavior.
custom-print-method?now compares the liveget-methodresult against the generic collection registrations;MultiFn's own dispatch cache does the heavy lifting, and all the staleness/invalidation logic disappears because every lookup sees the current registrations.*honor-print-method*dynamic var (default true) gates the feature, making it a per-context decision - the inspector, the debugger or cider-nrepl can bind it off wherever structural output is preferable.Numbers on a collection-heavy benchmark (100 prints of ~4000 nested values): master baseline ~80ms, the cached version ~87ms, this version ~102ms. With the var bound to false there's no overhead at all. I don't think the difference matters for a tooling printer, but if it does, flipping the default to false makes the feature free and purely opt-in - that's a policy call I'm leaving open here.
Net effect: about 50 lines less, no deftype, no atom, no concurrency reasoning.
cc @alexander-yakushev