Hi, On Thu, Jan 31, 2013 at 11:36 PM, Asbjørn <[email protected]> wrote: > This method is very slow. It seems the overhead of converting the > internal data to lists is quite high. Returning an iterator for the > outer list of rgba pixels did not improve the situation noticeably. > > Are there better (API) ways of doing this directly, that is, without > loading files from disk?
I think currently loading from disk is still the quickest method, especially as on a modern OS the contents of that file is cached in memory on doesn't actually have to be read from the physical disk usually. We could implement a more efficient way to assign the pixels though by letting it accept a buffer object, which you could then use to wrap the pixels without actually having to copy them into a python list. http://docs.python.org/3.3/c-api/buffer.html There is already a trick that you can use, it didn't work entirely before but I just committed a fix for that. Basically you use the foreach_set method which accepts a buffer object: http://www.blender.org/documentation/blender_python_api_2_65_9/bpy.types.bpy_prop_collection.html?highlight=foreach_get#bpy.types.bpy_prop_collection.foreach_set Example here. The inconvenient thing about this is you have to set the pixels for all layers/passes at once, but it should be quick if the lux C code can create the python buffer object. http://www.pasteall.org/39345/python Brecht. _______________________________________________ Bf-python mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-python
