[Python-ideas] Enhance reload

George Sakkis gsakkis at rutgers.edu
Sat Sep 29 17:01:56 CEST 2007

On 9/29/07, Joseph Maurer <clarkksv at yahoo.com> wrote:

I'm glad to hear it isn't a matter of whether it was useful or not.
> The way I implemented this feature in Slick-C is with indirection. In
> Python terms, this means that a separate data structure that isn't reference
> counted holds the method/function object data.  The method/function object
> is changed to just contain a pointer to it. The data structure which holds
> all method/function data should probably be a non-reference counted
> dictionary.  When a function is deleted, it's name remains in the dictionary
> but the entry needs to be changed to indicate that it is
> "null/invalid".  When a deleted function is called, an exception should be
> raised. Adding a function/method means replacing the data in the dictionary.
> This type of implementation is simple. There's an insignificant amount of
> overhead on a function/method call (i.e. instead of "func->data" you
> have  "func=*pfunc;if ( func->isInvalid() ) throw exception; else
> func->data" ).
> Technically this algorithm leaks memory since deleted functions/methods
> are never removed.  My response is who cares. When the interpreter cleanup
> everything function is called, you simple deallocate everything in the hash
> table.
> Does anyone know what level of effort would be needed for something like
> this?
> Is my proposed implementation a good one for Python?

You may want to take a look at a relevant Cookbook recipe:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20070929/ae4474b6/attachment.html>

More information about the Python-ideas mailing list