[Bf-python] Python API refactoring wiki

Campbell Barton cbarton at metavr.com
Fri Jan 27 13:41:12 CET 2006


Joe Eagar wrote:
> jmsoler at free.fr wrote:
>> Selon Campbell Barton <cbarton at metavr.com>:
>>
>>  
>>> Hey Guys, started a wiki page for python api refactoring.. check it 
>>> out.
>>> http://mediawiki.blender.org/index.php/BlenderDev/BpyApiDiscussion
>>>
>>>     
>>
>> About this :
>> " Will we maintain NMesh? (seems like a good time to get rid of it)",
>> just a word, create a simple vertex with Mesh is 60/70 times slower
>> than with NMesh .
>>   
>
> If NMesh was deprecated, would it be possible to write a python 
> wrapper around it?  That way existing scripts could use the wrapper 
> instead of having to do a full rewrite.
>
> And I noticed that in the verts.extend C function the vert list is 
> reallocated every time.  I would think that allocating extra space at 
> each call (so that the list is reallocated every 10 .extends, the 
> other 9 calls using this extra allocated space) would be faster, 
> although admittedly I've only done this for pointer arrays so I have 
> no experience with this sort of thing.
>
> joeedh
Hey JoeHeed,
 Have discussed an NMesh wrapper and its not such a bad idea, May try 
this sometime, though would probably never get 100% backwards compat 
with old scripts.
 
as for extend() allocating each time- hope people who have used python 
list extend get a hint that its not ment to be used like append()
This isnt quite as simple as it seems (Ken Correct me im wrong)- Since 
Mesh edits the mesh in place - having a mesh with memory allocated mut 
not used could cause a memory leak..
Its not like NMesh that has a PutRaw command or ob.update() - after 
every commant blender needs to have a usable mesh otherwise crashes 
happen fairly easerly...

If we want a thin wrapper and all its advantages we need to accept we'll 
need to program differently. - Document that its slower to do things one 
at a time and allow the user to make mistakes :).

With NMesh lots of people did
  mesh = NMesh.GetRaw(ob.data.name)
Without realizing that they were converting to NMesh twice... some 
bundeled scripts included with blender threw ob.data.name around all the 
time. (can be very slow on big meshes)

Im just saying that NMesh has been abused, Mesh can be too- But 
collecting a list of vectors before adding isnt that hard.

- Cam

-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list