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

PyType_Spec basicsize/itemsize should allow -1 for "inherit" #89688

Closed
encukou opened this issue Oct 19, 2021 · 3 comments
Closed

PyType_Spec basicsize/itemsize should allow -1 for "inherit" #89688

encukou opened this issue Oct 19, 2021 · 3 comments

Comments

@encukou
Copy link
Member

encukou commented Oct 19, 2021

BPO 45525
Nosy @encukou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-10-20.10:40:01.685>
created_at = <Date 2021-10-19.15:43:58.181>
labels = []
title = 'PyType_Spec basicsize/itemsize should allow -1 for "inherit"'
updated_at = <Date 2021-10-20.10:40:01.683>
user = 'https://github.com/encukou'

bugs.python.org fields:

activity = <Date 2021-10-20.10:40:01.683>
actor = 'petr.viktorin'
assignee = 'none'
closed = True
closed_date = <Date 2021-10-20.10:40:01.685>
closer = 'petr.viktorin'
components = []
creation = <Date 2021-10-19.15:43:58.181>
creator = 'petr.viktorin'
dependencies = []
files = []
hgrepos = []
issue_num = 45525
keywords = []
message_count = 2.0
messages = ['404311', '404421']
nosy_count = 1.0
nosy_names = ['petr.viktorin']
pr_nums = []
priority = 'normal'
resolution = 'postponed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue45525'
versions = []

@encukou
Copy link
Member Author

encukou commented Oct 19, 2021

For cases where you aren't adding new C-level state, especially if don't have the superclass' struct available, it would be good to allow inheriting basicsize/itemsize from the superclass.

(SuperType->tp_size is not easily usable for the same reason PyType_FromSpecWithBases exists: on MSVC, if SuperType comes from a different DLL, it is not a constant expression.)

@encukou
Copy link
Member Author

encukou commented Oct 20, 2021

Hm, after sleeping on it, I think I filed this too soon.
If you don't have the superclass's C memory layout (and you can't add new C-level state), it's not likely that you want to define a class in C.

I can construct theoretical cases where it might be useful, but IMO it should wait for an *actual* motivating use case. (The one I had was making a specific C-API test a bit easier to write, which is very weak.)

No need to have this sit on CPython's TODO list. I'll close this and let someone reopen (or file a new issue) if they actually need it.

@encukou encukou closed this as completed Oct 20, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@encukou
Copy link
Member Author

encukou commented May 27, 2022

FWIW, there is a use case now, along with a more general solution proposed: https://mail.python.org/archives/list/capi-sig@python.org/

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

No branches or pull requests

1 participant