[Bf-python] Vector data type

Campbell Barton cbarton at metavr.com
Mon Sep 25 07:38:21 CEST 2006


I was just looking and some areas for improvement.
and found the vector pytype,

typedef struct {
    PyObject_VAR_HEAD
    struct{
        float *py_data;        //python managed
        float *blend_data;    //blender managed
    }data;
    float *vec;                //1D array of data (alias)
    int size;
    int wrapped;            //is wrapped data?
    PyObject *coerced_object;
} VectorObject;


Looks like  theres 3 areas for  improvement.
*vec; points to either *py_data; and *blend_data;  depending on  the 
wrapped; state.
why not just remove  *py_data; and  *blend_data; and use vec only??

    int size;
    int wrapped;            //is wrapped data?

Could both be shorts? -would save 32bits, seems overkill again, 64 bits 
of data- for what is a total of 6 possible states.

*coerced_object;

- We could have vector math with floats and matrices without this.

Anyone object to an attempt to optimize  this struct for size?

-- 
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