[Bf-python] Vector data type

Gilbert, Joseph T. jgilbert at tigr.ORG
Mon Sep 25 16:48:46 CEST 2006


""" why not just remove  *py_data; and  *blend_data; and use vec
only??"""
The flag value wasn't added until later as a 'getter'. At the time I
thought that the struct was the best way to represent the 2 states that
this object could be in. It was not optimized to be small. It's possible
that a flag+float pointer would suffice for the purposes of size, even
if a little less safe. I still think the struct is a nicer solution
though.

""" Could both be shorts?"""
No reason not to.

""" We could have vector math with floats and matrices without this"""
Removal of the PyObject* will cause all mathutils math to fail as the
coercion routines will no longer function.

Are we having some sort of memory problem using vectors?

-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
Barton
Sent: Monday, September 25, 2006 1:38 AM
To: Blender Foundation Python list
Subject: [Bf-python] Vector data type

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