[Bf-python] Hashing Vectors
Campbell Barton
cbarton at metavr.com
Wed Jul 19 00:12:20 CEST 2006
Joe Eagar wrote:
> Martin Poirier wrote:
>> --- Joe Eagar <joeedh at gmail.com> wrote:
>>
>> Errr, just make a tuple of the floats then, no need to
>> mess around like that.
>>
>> The problem is not that they are floats, the problem
>> is that vector objects are mutable.
>>
>> This is only a problem if you want to use vectors as
>> dict keys or as part of a set.
>>
>> Making a tuple out of them is *the* way to solve that.
>> Making vector immutable is not a viable option (due to
>> how wrapped vectors currently work).
>>
>> Martin
>>
> Well I wasn't being totally serious. it just seemed like a fun (if
> probably unpractical) solution.
>
> Joe
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.
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.
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
--
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