KEMBAR78
gh-76187: Document the `c` typecode for `multiprocessing.Array`. by tomasr8 · Pull Request #132504 · python/cpython · GitHub
Skip to content

Conversation

@tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Apr 14, 2025

I linked to the ctypes types table and added this sentence:

In addition, the c typecode is an alias for :class:ctypes.c_char.

The rest of the diff is just wrapping.


📚 Documentation preview 📚: https://cpython-previews--132504.org.readthedocs.build/

Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

Could you also mention that the w typecode of array is not supported? (glancing at the code, it is missing from Lib/multiprocessing/sharedctypes.py)

@tomasr8
Copy link
Member Author

tomasr8 commented Apr 14, 2025

Could you also mention that the w typecode of array is not supported? (glancing at the code, it is missing from Lib/multiprocessing/sharedctypes.py)

Will do. Do you think it's worth to improve the error message for invalid typecodes as well? TypeError: this type has no size is a bit cryptic imo. Compare with the array.array error:

>>> array('x')
...
ValueError: bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d)

(And I just noticed that the error message doesn't include 'w' 😆 )

@gpshead
Copy link
Member

gpshead commented Apr 14, 2025

Yeah, improving the error message and/or even adding 'w' support are all also viable options. I expect this part of the code was inherited from the original upstream project multiprocessing came from and likely hasn't been meaningfully touched since? It's a dark corner.

@tomasr8
Copy link
Member Author

tomasr8 commented Apr 14, 2025

Updated to mention that 'w' is not supported.

improving the error message and/or even adding 'w' support are all also viable options.

I'll send a patch to improve the error message and align it with that of array.array. I'm not that familiar with this module so I'm not sure how useful it'd be to add support for 'w'. I'll check how many changes that would require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants