[Bf-python] [PATCH v3] Add BMElemSeq.sort

Antonio Ospite ospite at studenti.unina.it
Thu Jun 21 15:00:44 CEST 2012


On Sat, 9 Jun 2012 18:40:33 +0200
Campbell Barton <ideasman42 at gmail.com> wrote:

> Good work - sent new review
> http://codereview.appspot.com/6305077/
> 
> python is currently single threaded so you could use a static var
> here, though I would like to avoid this where possible.
>

Here is a v3 attached.

Changes since v2:

  - Fixed compilation warning about incompatible type of the comparison
    functions.
  - Use qsort: rely on a global variable to sort according to the 'keys'
    array
  - Don't use gotos
  - Don't use PyNumber_Check(), it's faster to check the return value of
    PyFloat_AsDouble() directly
  - Don't call BM_mesh_elem_index_ensure(), leave the indices untouched,
    mention BMEelemSeq.index_update() in the docstring.

I didn't move the check about (BMIterType)self->itype), see [1],
because I use elem_map_idx in there _after_ this has been allocated. If
I wanted to check self->itype before I had to do a check on the
type again later to decide what elements we are dealing with anyways.

If you've got any other suggestions, let me know.

I still think the old version with gotos were easier on the eyes :)

Thanks,
   Antonio

[1]
http://codereview.appspot.com/6305077/diff/1/source/blender/python/bmesh/bmesh_py_types.c#newcode2257

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-BMElemSeq.sort-method.patch
Type: text/x-diff
Size: 8352 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20120621/60dc5450/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BMElemSeq_sort_test.py
Type: text/x-python
Size: 3239 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20120621/60dc5450/attachment.py>


More information about the Bf-python mailing list