[Bf-committers] python mathutils api update proposal

Dan Eicher dan at trollwerks.org
Fri Feb 4 01:28:16 CET 2011


On Thu, Feb 3, 2011 at 2:54 PM, Campbell Barton <ideasman42 at gmail.com> wrote:

> -- snip --
>
> To see what I mean about sloppy argument parsing, see comparison of
> 2.4x and 2.5x code below - both the same function though 2.5x uses
> mathutils_array_parse() utility function.
> The 2.4x code even had a memory leak for some time (refcount error).
>
> # --- 2.5x Code
> -- snip --
It's actually pretty easy to do this type of overloading, you just
need python to do the heavy lifting through
PyArg_ParseTuple[AndKeywords]. Pybindgen uses this method in its
generated code and it works very well.

The gist -- multiple functions that the main method calls and once it
finds one that doesn't throw an exception (from function args not
matching) then that's the one it uses. The code is nicely separated so
you don't end up with a bunch of if else blocks and everyone is happy.

I would be simpler to just show some code than describe it methinks

Dan


More information about the Bf-committers mailing list