My script is taking 12 hours+ any suggestions?

Sean Ross sross at connectmail.carleton.ca
Sat Aug 30 11:21:28 EDT 2003


"Sean Ross" <sross at connectmail.carleton.ca> wrote in message
news:0uW3b.4392$_F1.665478 at news20.bellglobal.com...
[re: dictionary record of shared normals]
>
> But, this takes up more space than the jagged list version. And the
look-up
> is slower.

Actually, that's wrong. Because of the way I built the dictionary

SHARED = {0: [0,1,3],  # v0 shares normals with itself, v1 and v3
                      1: [0,1,3],
                      2: [2]
                      3: [0,1,3]}

is actually more like this

SHARED = {0: <list object at 17970096>,
                      1: <list object at 17970096>,
                      3: <list object at 17970096>,
                      2: <list object at 68520397>}

where <list object at 17970096> is [0,1,3]
and <list object at 68520397> is [2]

So, we're only using space for two lists, not four (plus space for
the dictionary, it's keys, yada, yada). As an added benefit,
the look-up for shared normals is quick and easy as well:

# v0.share_normal(v3)
SHARED[0] is SHARED[3]

where we only have to check the identity of the lists being referenced.

Another benefit of this is, if you add a new vert to the dictionary after
you've processed the file, if the new vert shares normals with any of the
verts in the dictionary, you just add it to the list of the first one that
you
come across, and all of the other verts that this new vert would share
normals with will also have that new verts index in their share list. Not
bad.

So, it looks to me like this may be the best of the three methods I've
presented: It calls share_normal() at most as many times as the jagged
list method (and probably far fewer times). It updates easily and the
effects
are distributed. And the subsequent share normal checks by identity are
quick
and efficient. But, hey, I could be wrong. For one thing, I don't even know
if
you need to do this type of thing...

OK, then. Have fun,
Sean






More information about the Python-list mailing list