[Python-Dev] Second round: arbitrary function and method attributes

bwarsaw@cnri.reston.va.us bwarsaw@cnri.reston.va.us
Wed, 12 Apr 2000 11:56:18 -0400 (EDT)


>>>>> "GS" == Greg Stein <gstein@lyra.org> writes:

    GS> In the instancemethod_setattro function, it might be nice to
    GS> do the speed optimization and test for sname[0] == 'i' before
    GS> hitting the strcmp() calls.

Yeah, you could do that, but it complicates the code and the win seems
negligable.

    GS> Oh: policy question: I would think that these attributes
    GS> *should* be available in restricted mode. They aren't "sneaky"
    GS> like the builtin attributes.

Hmm, good point.  That does simplify the code too.  I wonder if the
__dict__ itself should be restricted, but that doesn't seem like it
would buy you much.  We don't need to restrict them in classobject
anyway, because they are already restricted in funcobject (which ends
up getting the call anyway).  It might be reasonable to relax that for
arbitrary func attrs.

    GS> Rather than
    GS> PyMapping_Get/SetItemString()... PyObject_Get/SetItem() should
    GS> be used. They apply to mappings and will be faster. Note that
    GS> (internally) the PyMapping_Get/SetItemString use the latter
    GS> forms (after constructing a string object(!)).  ... whoops. I
    GS> see that the function object doesn't use the ?etattro()
    GS> variants. hrm.

Okay cool.  Made these changes and `attro'd 'em too.

    GS> The stuff is looking really good!

Thanks!
-Barry