Forum: Poser Python Scripting


Subject: Copies, deep copies, malloc, and RAM consumption

Cage opened this issue on Jan 01, 2007 · 13 posts


Cage posted Tue, 02 January 2007 at 12:53 AM

Any idea if and/or how there are circular references here?  First, I create a list from Geometry().Sets(), then I use that list to create a list of edges.  The list created by polyverts() is the pverts used by polyedges().

#--------------------------------------------------
def polyverts(geom,polys):  #return the sets list broken down by polygon       
    pv = []
    gset = geom.Sets()
    for p in polys:
        l = p.NumVertices()
        s = p.Start()
        e = s + l
        vl = [v for v in gset[s:e]]           
        pv.append(vl)       
    return pv

def polyedges(geom,pverts): #return the start, end vertices for each edge in the polygon       
    edges = []
    for p in pverts:           
        poly = []
        for v in range(len(p)):
            if v != len(p)-1:
                e = p[v], p[v+1], vecsub(coord_list(geom,p[v+1]),coord_list(geom,p[v]))
            else:
                e = p[v], p[0], vecsub(coord_list(geom,p[0]),coord_list(geom,p[v]))
            poly.append(e)
        edges.append(poly)       
    return edges
#--------------------------------------------------------------------

So does the generator object used in polyverts() create shallow copy references to the values in Geometry().Sets(), or does it create deep copy references back to the Sets() list itself?  And when I append p[v] (etc) in polyedges(), do I create deep or shallow references?  Just exactly where am I making circles?  Any ideas?

Sorry to be a pain.  This is a rather new and mysterious topic for me.  Python keeps surprising me....

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.