[Bf-python] foo_CheckPyObject() procedure vs BPy_foo_Check() macro

Joseph Gilbert jgilbert at tigr.ORG
Thu Mar 15 14:22:49 CET 2007


The function + the header declaration was the old way. The definition is 
the new way.  Because modules have been written at various times they 
tend to use one or the other. My vote is for the #define to be the standard.

Ken Hughes wrote:
> Another thing for future clean-ups:
>
> Most objects have two ways define to check their type: the 
> foo_CheckPyObject() procedure and the BPy_foo_Check() macro.  Both do 
> the same thing:
>
> int foo_CheckPyObject( PyObject * pyobj )
> {
>         return ( pyobj->ob_type == &foo_Type );
> }
>
> #define BPy_foo_Check(v) ((v)->ob_type==&foo_Type)
>
> Is there a reason to have both?  If not, which should we keep?  I 
> prefer the macro since it's quicker and I assume not much larger (if 
> at all) than the call overhead.
>
> Ken
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list