@@ -893,12 +893,26 @@ native or user class, or enum. Nested array types (like ``Array[Array[int]]``) a
893893Packed arrays
894894^^^^^^^^^^^^^
895895
896- GDScript arrays are allocated linearly in memory for speed.
897- Large arrays (more than tens of thousands of elements) may however cause
898- memory fragmentation. If this is a concern, special types of
899- arrays are available. These only accept a single data type. They avoid memory
900- fragmentation and use less memory, but are atomic and tend to run slower than generic
901- arrays. They are therefore only recommended to use for large data sets:
896+ PackedArrays are generally faster to iterate on and modify compared to a typed
897+ Array of the same type (e.g. PackedInt64Array versus Array[int]) and consume
898+ less memory. In the worst case, they are expected to be as fast as an untyped
899+ Array. Conversely, non-Packed Arrays (typed or not) have extra convenience
900+ methods such as :ref: `Array.map <class_Array_method_map >` that PackedArrays
901+ lack. Consult the :ref: `class reference <class_PackedFloat32Array >` for details
902+ on the methods available. Typed Arrays are generally faster to iterate on and
903+ modify than untyped Arrays.
904+
905+ While all Arrays can cause memory fragmentation when they become large enough,
906+ if memory usage and performance (iteration and modification speed) is a concern
907+ and the type of data you're storing is compatible with one of the ``Packed ``
908+ Array types, then using those may yield improvements. However, if you do not
909+ have such concerns (e.g. the size of your array does not reach the tens of
910+ thousands of elements) it is likely more helpful to use regular or typed
911+ Arrays, as they provide convenience methods that can make your code easier to
912+ write and maintain (and potentially faster if your data requires such
913+ operations a lot). If the data you will store is of a known type (including
914+ your own defined classes), prefer to use a typed Array as it may yield better
915+ performance in iteration and modification compared to an untyped Array.
902916
903917- :ref: `PackedByteArray <class_PackedByteArray >`: An array of bytes (integers from 0 to 255).
904918- :ref: `PackedInt32Array <class_PackedInt32Array >`: An array of 32-bit integers.
0 commit comments