Skip to content

Conversation

davidhewitt
Copy link
Member

Closes #5393

This PR adds CastError as a new error type, leaving DowncastError as-is but deprecated.

Across the codebase I swap all DowncastError for CastError, and same for DowncastIntoError -> CastIntoError.

Copy link

codspeed-hq bot commented Sep 27, 2025

CodSpeed Performance Report

Merging #5468 will degrade performances by 10.16%

Comparing davidhewitt:cast-error (d2a8508) with main (da618c7)

Summary

❌ 1 regression
✅ 97 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
not_a_list_via_extract_enum 17.6 µs 19.6 µs -10.16%

/// Like `downcast_exact` but takes ownership of `self`.
// FIXME(icxolu) deprecate in favor of `Bound::cast_into_exact`
fn downcast_into_exact<T>(self) -> Result<Bound<'py, T>, DowncastIntoError<'py>>
fn downcast_into_exact<T>(self) -> Result<Bound<'py, T>, CastIntoError<'py>>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether we should just deprecate these as well now, and keep the old error type.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's a really good idea, let me send a PR to deprecate those separately, I'll revert the error type here for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Proabably need #5472 to merge first.

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.

rename DowncastError into CastError
2 participants