[Bf-python] Hashing Vectors

Martin Poirier theeth at yahoo.com
Wed Jul 19 02:10:37 CEST 2006



--- Campbell Barton <cbarton at metavr.com> wrote:

> If hashing a vector at its current state is evil,
> could there be a way to...
> a) Speed up conversion to a tuple? - not sure how
> this might be done, 
> have a vec.tuple() function to avoid python
> iterating over 2,3,4 axis 
> for every conversion.

Did you try doing it manually? You'll always know in
advance the number of dimensions you're dealing with,
so just do:

(v[0], v[1], v[2]) instead of tupple(v)


> b) Have a method that returns a non tuple hashable 
> hashable type - 
> somthing like vec.key() which could return a long
> int or whatever ends 
> up being best to hash. - document that this is
> location dependant and 
> will change of the location changes.

It would have to be tupple based, that is pretty much
the cleanest way to make an immutable vector, short of
packing everything non-destructively in an int.

> c) Have a new iterator datatype for vector arrays,
> with functions like 
> adding a unique vector, and other useful operations-
> such an array would 
> be  useful for Blender.Geometry


A Vector Set.

Thinking about this rang a bell though. Vector's are
floating point data, so any test done on equality is
potentially wrong due to float errors.

Martin

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Bf-python mailing list