[PythonCAD] Weak-references in Python

Art Haas ahaas at airmail.net
Wed Dec 3 13:14:00 EST 2003


Hi.

Now that the Thanksgiving holidays are over it's time to get moving
with some PythonCAD coding. One thing I'd like to do is investigate the
use of weak references in the code.

The python development list had discussed these things recently, though
they have been part of python since the 2.1 release. Weak references are
documented in the 'libweakref.tex' file in the Python documentation, and
based on the following PEP:

http://python.sourceforge.net/peps/pep-0205.html

It appears that weak references have a number of good potential uses in
PythonCAD as using these things will ensure that the various entities in
a drawing don't have stray references which prohibit the entity's
destruction and memory reclamation. This behavior is very desirable as a
drawing with many entities could take up a great deal of memory, and
releasing that memory is important to keep the overall memory usage
down.

There is no use of weak references in the current code at present. I'll
be poking around a bit for info on them, and try them out in a few
places as well. I'm hoping that there are people on the mailing list
with some experience in using them and can write to the list regarding
their experiences - good, bad, or ugly (ah-yi-ah-yi-ah)!

Near the end of this year I'll write up some stuff regarding the state
of the program, and the good and bad things that I think this first year
of public release has shown. I'll also be writing up some things
regarding the direction of development over the next year, both short
and long term. Printing and hatching are certainly on the list, as
well as improving the editing (moving, changing linetypes and colors,
etc) of entities will be on the list as well. Another goal is improving
the code itself - fixing various places where the code is structured
poorly or can be written in a more "pythonic" way, for example.

Art
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822



More information about the PythonCAD mailing list