[IndexedCatalog] Signals.py

Christian Robottom Reis kiko at async.com.br
Sun Jun 19 18:02:50 BRT 2005


On Sun, Jun 19, 2005 at 12:38:08AM -0700, David M. Cook wrote:
> I'd like to get this code working with a recent version of Python, but I
> don't understand the stuff about im_self, im_class, func2name, name2func,
> simple_import, etc.  Can someone explain why this was neccessary?

You appear to have a number of different questions -- we can probably
explain why some things in IC are as they is, but you'll need to tell us
what you want to know :-)

Johan has merged today preliminary IC support for new-style classes; if
you'd like to try that out, it should (hopefully) work with a recent
version of python.

On the points I can surmise from your email:

    - func2name and name2func are used because we pickle the signal
      callback list with persisted objects. Because function objects
      aren't picklable we need to store them as strings and do this
      conversion.

    - im_self and im_class are normal Python properties of method objects:

        >>> class Foo:
        ...   def a(): pass
        ... 
        >>> f = Foo()
        >>> dir(f.a)
        ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__',
         '__get__', '__getattribute__', '__hash__', '__init__', '__new__',
         '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
         'im_class', 'im_func', 'im_self']
    
      They are used in func2name to allow access to the class and module
      the function comes from.

    - We use our own import hook --- simple_import actually calls
      _myimport; the reason being that when we do a name2type we need to
      do an import of the named module. Again this is done because we
      can't pickle types (last I checked, too).

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3376 0125


More information about the IndexedCatalog mailing list