Editors and books

Jason Stokes jstok at bluedog.apana.org.au
Tue Apr 18 12:08:33 EDT 2000


Jeff Massung wrote in message ...
>First, I'd like to give my undying praise to PYTHON: Essential Reference,
by
>David M. Beazley. I'm an accomplished C/C++ programmer who wanted to learn
>Python. This book was IT! Anyone whose reading this that is in my shoes -
>get this book! It's some of the best $35 I've spent!


I like the book a lot too.  Sure, a lot of it is duplicated in the online
material, but it's concise, better presented, and perfect for the
accomplished programmer who can learn other languages fast.

>Also, on another NG there's talk about Python, and how it does (and still
>doesn't) do garbage collecting. Could someone here expand on it so I know
>what it can and can't do? Memory is a big issue in my project and I need to
>know how to structure my program so that garbage is collected. Thanks
>again!!


Python uses a reference counting scheme to collect unused objects.  Each
object stores a count of how many references refer to it.  When this drops
to zero, the object is deallocated.  This scheme has the usual drawbacks of
reference counting -- if there's a data structure whose object reference
graph involves cycles (eg a doubly linked list) the reference counts of
those objects will never reach zero because they refer to each other, even
if the base of the list becomes unreachable.

To deal with this you need to create specific destruction routines for your
data structures that run through and break these references, eg by setting
them to null.

This is annoying, but since you're used to C++ you're used to it (it's the
same scheme used by reference counting smart pointers.)  There's no
language-level reason why Python can't have true garbage collection, and in
fact true garbage collection for Python has recently been implemented and
with luck we'll see it become a standard part of Python implementations.


>-- Jeff Massung (jmassung at magpiesystems.com)
>-- Lead programmer for Magpie Systems
>-- Bringing smart pigs to the pipeline industry!

Oh wow!  I bet that's more interesting than working on inventory databases
or visual basic scripts....





More information about the Python-list mailing list