PyAPI: Allow prop collection raw array read access for non-editable props #114063

Merged
Bastien Montagne merged 4 commits from Mysteryem/blender:prop_collection_raw_read_access into main 2023-11-06 15:51:16 +01:00

4 Commits

Author SHA1 Message Date
Thomas Barlow c631d2b946 Merge branch 'main' into prop_collection_raw_read_access
buildbot/vexp-code-patch-coordinator Build done. Details
2023-11-06 12:41:22 +00:00
Thomas Barlow 5e50f0c733 Change the new `set` parameter of RNA_property_collection_raw_array to bool
buildbot/vexp-code-patch-coordinator Build done. Details
2023-10-30 17:01:18 +00:00
Thomas Barlow 54697d6209 make format 2023-10-23 13:56:52 +01:00
Thomas Barlow 886d92bcb1 PyAPI: Allow prop collection raw array read access for non-editable props
Non-editable prop collection items would always fall back to the slower
loop in rna_raw_access.

This patch changes RNA_property_collection_raw_array to only fail with
non-editable items when intending to set values, allowing for the faster
raw array access to occur when intending to read values.

This brings the Python API bpy_prop_collection.foreach_get performance
of Mesh.vertex_normals/polygon_normals/corner_normals up to the same
speed as generic FLOAT_VECTOR attributes with the same domains.

Given a mesh with 393216 corners:
Using foreach_get with the "vector" prop and a compatible buffer object:
- Corner vector attribute: ~0.9ms
- Corner normals (before): ~7.9ms
- Corner normals (after):  ~0.9ms
Using foreach_get with the "vector" prop and a Python list:
- Corner vector attribute: ~11.0ms
- Corner normals (before): ~18.0ms
- Corner normals (after):  ~11.0ms
2023-10-23 13:53:48 +01:00