[Python-Dev] gc.garbage
Tim Peters
tim@zope.com
Thu, 29 Nov 2001 17:25:12 -0500
[Neil Schemenauer, on the gc.garbage docs as of about a week ago]
> It's not clear because it's nonsense. I think I mean to say something
> about the gc.garbage binding. If you do something like:
>
> gc.garbage = "ha ha"
>
> then the list is garbage is forever inaccessible from within Python.
I've since tried to repair the docs, to point out that rebinding gc.garbage
is a Bad Idea but mutating it may be a Good one. BTW, I expect it's more
likely people will get in trouble via:
gc.garbage = []
I expect that because I did it once <wink>.
> Is there some way to prevent people from assigning to certain module
> variables?
Not that I know of. If you're terribly concerned, gc could look up
"garbage" in its dict on each access. That's what, e.g., PRINT_ITEM does
with sys.stdout. Then it would also have to check that it's a list, etc.
But I'd be keener to see new words spelling out which parts of the gc
interface are and aren't intended "to work" across releases ...