Memory efficient way to store many numbers (floats, ints) in a .blend file For my addon I need to store large amounts of data in a .blend file (mostly floats, but other types are possible as well). 

I tried using a normal CollectionProperty. Performance wise this works fine (with foreach_get and foreach_set). However some rough measures show that Blender stores roughly 128 bytes per float this way, which is quite a lot of overhead and therefor not really acceptable.

Is there a better solution to this problem?
Collections are indeed not ideal for this use case.

You can store raw arrays in ID properties, which will native data types that don't take up excessive space in memory or on-disk. eg:

bpy.context.object["my_array"] = [1.0, 2.0, 3.0]


You can assign from an array type too:

import array
data = array.array('f', [1, 2, 3])
bpy.context.object["my_array"] = data


Internally float values are stored with double precision (8 bytes per value), as with Python's floats.