A way to avoid copying update_slot of type_setattro ?

Discussion in 'Python' started by Boris Boutillier, Nov 4, 2003.

  1. Hi all,

    I'm writing a Python C-Extension module with new classes.
    These classes must be setable by the user. As default type setattr
    doesn't allow Extension classes to be setable, I have to write a
    specific setattr on my Metaclasses.
    The first part of a type setattr is to call PyObject_GenericSetAttr which
    is in the API, but next if the user change one of the slot I have to
    update slots. And in my case the user can modify slots, it is even
    encouraged (I am writing a database for netlist description of electronic
    circuit and the use may want that MyNet1 + MyNet2 instantiate a specific
    addition module, so he'll have to set a slot, __add__).

    The problem is that update_slot is not in the API, and is not easy to copy
    paste, so before doing it I'd like to know if someone already got this
    problem and found some elegant solution.
    One possible python enhancement would be to add a SETABLE_CLASS flag to
    python classes, defaulting to 0 (for backward compatibility) and change
    the check done in type_setattro, set_bases, set_bases to check for this
    flag, not HEAPTYPE, I'll make it, test it and send the patch when I'll
    have time for that.

    Thanks in advance.

    Boris
     
    Boris Boutillier, Nov 4, 2003
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.