[Python-Dev] 2.5 and beyond (original) (raw)
Thomas Heller theller at python.net
Tue Jul 4 13:35:13 CEST 2006
- Previous message: [Python-Dev] Restricted execution: what's the threat model?
- Next message: [Python-Dev] 2.5 and beyond
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neal Norwitz schrieb:
I'm glad to see Anthony ratcheting down. At this point, we need to be fixing bugs and improving doc. Maybe Anthony and I should have a contest to see who can revert the most changes. :-) Neal (and/or Anthony),
I would like to ask about the possibility to add some improvements to ctypes in Python 2.5, although the feature freeze is now in effect. Hopefully former third-party libraries can have the freeze relaxed somewhat;-).
I intend to do these changes, the first is a small and trivial one, but allows a lot of flexibility:
- Remove the restriction that the argtypes attribute of foreign functions must be ctypes types. Instead they are only required to implement a .from_param class method. The advantage is that custom objects can be used as function parameters. One usecase is to allow numpy arrays as function parameters without any conversion - this change at least allows to code this in Python. The patch is attached as from_param.patch.
The second one is more involved, and not yet complete. I can post the patch or a link to it for review when it is implemented completely:
- Implement the array_struct attribute as describes by the numpy pep at http://numpy.scipy.org/array_interface.html. The properties needed to implement the array_struct attribute could be calculated from a given ctypes array type, however, it would be more efficient to calculate them at type creation time. This requires the StgDSictObject that holds information about the ctypes type to grow a few fields: 'int nd' - contains the number of dimensions, 'char typekind' - a struct-like character for the item type, and 'Py_intptr_t *shape' - an array of size 'nd' containing shape information.
Thanks for investigating this, Thomas -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: from_param.patch Url: http://mail.python.org/pipermail/python-dev/attachments/20060704/3c0500e4/attachment.pot
- Previous message: [Python-Dev] Restricted execution: what's the threat model?
- Next message: [Python-Dev] 2.5 and beyond
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]