how to do overloads?



Hi all,

I'm finishing up a goi binding for my image processing library and I
have two questions left to resolve:

1. I have a file with a few useful helper functions. It does things
like defining obvious operator overloads, stuff like that.

At the moment you import it like this:

   from gi.repository import Vips
   import vips_additions

the second import patches the Vips object to add the new stuff. Is
this sensible? Should I look into overrides instead? Are there some
docs or examples somewhere on best use of the override system?

2. I'd like to add some class methods to some of the classes gio
generates. At the moment I just patch them in with a series of:

   setattr(Vips.Image, nickname, classmethod(method))

But this hurting my startup time, there are a lot of these things and
I find them by introspecting another library. I'd love to be able to
defer the introspection until member lookup time, perhaps by
overriding getattr on the class object.

I've spent some time looking into this but not found an easy way to do
it. Does anyone have any good ideas?

Many thanks!

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]