Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type_object: remove layout and base type from PyTypeInfo #1596

Merged
merged 1 commit into from
May 7, 2021

Conversation

davidhewitt
Copy link
Member

This PR removes some associated types from PyTypeInfo which are really just implementation details of #[pyclass]:

  • Layout: moved to PyClassImpl. This doesn't make sense in the long term anyway, because if we inherit from native types where we don't know the layout information (Extend Python Class from Rust #991, Support subclassing from native types in abi3 #1344) we need #[pyclass] to work without layout information.
  • BaseType - moved to PyClassImpl. Not all Python types have a base type (e.g. PyAny), or we might not statically know them (e.g. Extend Python Class from Rust #991). All #[pyclass] do have a base type and we'll always know what it is.
  • BaseLayout - removed entirely.
  • Intitializer - moved to PyClassBaseType (which is renamed from PyBaseTypeUtils).

Making this change frees us up to make internal implementation changes to eventually support #991 and #1344.

In addition, it also simplifies a lot of trait bounds dotted around the public interface and simplifies the macros in types/mod.rs.

Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

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

LGTM.

@davidhewitt
Copy link
Member Author

davidhewitt commented May 7, 2021

(I'm going to add some more tests before merging) EDIT: the lines which codecov reports as not covered are all trait bounds and stuff like that which can't be covered anyway. Strange.

@davidhewitt davidhewitt merged commit 4613b3d into PyO3:main May 7, 2021
@davidhewitt davidhewitt deleted the remove-pytypeinfo-layout branch May 7, 2021 21:32
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.

None yet

2 participants