Skip to content

Conversation

@carljm
Copy link
Contributor

@carljm carljm commented Apr 14, 2025

Summary

Allows us to establish that two literals do not have a subtype relationship with each other, without having to fallback to a typeshed Instance type, which is comparatively slow.

Improves the performance of the many-string-literals union benchmark by 5x.

Test Plan

cargo test -p red_knot_python_semantic and cargo bench --bench red_knot.

@carljm carljm added the ty Multi-file analysis & type inference label Apr 14, 2025
@github-actions
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅

@codspeed-hq
Copy link

codspeed-hq bot commented Apr 14, 2025

CodSpeed Performance Report

Merging #17394 will improve performances by ×5.1

Comparing cjm/bigunions2 (c0f7346) with cjm/bigunions (91b5c91)

Summary

⚡ 1 improvements
✅ 32 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
red_knot_micro[many_string_assignments] 518.3 ms 100.9 ms ×5.1

Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Nice!

Base automatically changed from cjm/bigunions to main April 14, 2025 16:40
@carljm carljm merged commit e2a38e4 into main Apr 14, 2025
23 checks passed
@carljm carljm deleted the cjm/bigunions2 branch April 14, 2025 16:42
@AlexWaygood AlexWaygood added the performance Potential performance improvement label Apr 14, 2025
dcreager added a commit that referenced this pull request Apr 15, 2025
* main: (31 commits)
  [red-knot] Add some knowledge of `__all__` to `*`-import machinery (#17373)
  Update taiki-e/install-action digest to be7c31b (#17379)
  Update Rust crate mimalloc to v0.1.46 (#17382)
  Update PyO3/maturin-action action to v1.49.1 (#17384)
  Update Rust crate anyhow to v1.0.98 (#17380)
  dependencies: switch from `chrono` to `jiff`
  Update Rust crate bstr to v1.12.0 (#17385)
  [red-knot] Further optimize `*`-import visibility constraints (#17375)
  [red-knot] Minor 'member_lookup_with_policy' fix (#17407)
  [red-knot] Initial support for `dataclass`es (#17353)
  Sync vendored typeshed stubs (#17402)
  [red-knot] improve function/bound method type display (#17294)
  [red-knot] Move relation methods from `CallableType` to `Signature` (#17365)
  [syntax-errors] `await` outside async functions (#17363)
  [red-knot] optimize is_subtype_of for literals (#17394)
  [red-knot] add a large-union-of-string-literals benchmark (#17393)
  Update pre-commit dependencies (#17383)
  [red-knot] mypy_primer: Fail job on panic or internal errors (#17389)
  [red-knot] Document limitations of diagnostics-silencing in unreachable code (#17387)
  [red-knot] detect unreachable attribute assignments (#16852)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants