[Python-3000] adding @abstractmethods after class creation

Guido van Rossum guido at python.org
Wed Apr 25 06:29:22 CEST 2007


On 4/24/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> On 4/24/07, Calvin Spealman <ironfroggy at gmail.com> wrote:
> > Or could __abstractmethods__ be created dynamically? Which would be
> > used less, __abstractmethods__ or setting class attributes, that it
> > would be OK to be a bit slower?
>
> I considered that, but __abstractmethods__ gets checked at every class
> instantiation (as I understand it).  That means that
> __abstractmethods__ has to be fast. I assumed that was why Guido
> introduced it in the first place...

Check the patch on SF (referenced by the PEP now). The instantiation
code only checks a bit in tp_flags, which is set at class creation
time iff __abstractmethods__ is non-empty.

I'm not sure what the point would be of supporting dynamically
modifying ABCs -- it looks like you're just exploring the corners of
the semantics rather than providing actual use cases.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list