Message132926
The attached patch seems to correct this issue. It contains the test attached yesterday, and it passes now.
I factored out the winner calculation from type_new to a new _PyType_CalculateWinner function, and type_new calls this. I've put the declaration of this function into object.h, so __build_class__ can also call it, instead of using the metaclass of the first base. (Am I correct in thinking that the underscore prefix keeps it out of the public API?)
A slight problem may be, that in some cases this function will be called twice. But it is quite simple, so I don't think it matters much:
Without patch:
$ ./python -m timeit -- "class A(type): pass
class B: pass
class C(metaclass=A): pass
class D(B, C): pass
"
10000 loops, best of 3: 371 usec per loop
With patch:
$ ./python -m timeit -- "class A(type): pass
class B: pass
class C(metaclass=A): pass
class D(B, C): pass
"
10000 loops, best of 3: 381 usec per loop
(Note, that I generated the patch with hg extdiff, because the output of hg qdiff was much more unreadable than simple diff. I can provide an equivalent patch generated by hg if needed.) |
|
Date |
User |
Action |
Args |
2011-04-04 09:50:46 | daniel.urban | set | recipients:
+ daniel.urban, gvanrossum, georg.brandl, terry.reedy, amaury.forgeotdarc, rodsenra, pwerneck, benjamin.peterson |
2011-04-04 09:50:46 | daniel.urban | set | messageid: <1301910646.82.0.17268612839.issue1294232@psf.upfronthosting.co.za> |
2011-04-04 09:50:46 | daniel.urban | link | issue1294232 messages |
2011-04-04 09:50:45 | daniel.urban | create | |
|