constructors (Re: [Bf-python] More Proposed API changes.)
Joe Eagar
joeedh at gmail.com
Tue Mar 13 00:19:23 CET 2007
Joseph Gilbert wrote:
> Joe Eagar wrote:
>> So if a user does, "mesh = bpy.Mesh()", is he going to realize that
>> mesh is automatically added to bpy.meshes? What will he think, when
>> he realizes it isn't garbaged collected?
> This confuses the point. Calling a class constructor OR a factory
> function will cause a datablock to be added to G.main. Garbage
> collection occurs on wrapped instance of a class. This occurs in the
> current api if i call "m = Mesh.new()" and m goes out of scope. m
> gets deallocated but a new mesh is found in G.main.
>
> Having been involved with this project for a long time I know where
> suggestions end up, but i thought i'd speak up anyway.
I was talking from the point of view of a user. Users don't know the
details of how python wrapping works. They don't know about G.main, or
anything like that.
The problem with constructors is they imply the created object is fully
under the control of the script author, when really it is not. For
example, you can create a mesh, but if you want to delete it you'll have
to save-reload the file. Or you have a piece of wrapped data, like
perhaps an object, attached to a Registry dict, and a user undos then
redos; you might get corrupt data.
Joe.
More information about the Bf-python
mailing list