消息 [132926]
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.) |
|
| 日期 |
用户 |
动作 |
参数 |
| 2011-04-04 09:50:46 | daniel.urban | 修改 | recipients:
+ daniel.urban, gvanrossum, georg.brandl, terry.reedy, amaury.forgeotdarc, rodsenra, pwerneck, benjamin.peterson |
| 2011-04-04 09:50:46 | daniel.urban | 修改 | messageid: <1301910646.82.0.17268612839.issue1294232@psf.upfronthosting.co.za> |
| 2011-04-04 09:50:46 | daniel.urban | 链接 | issue1294232 messages |
| 2011-04-04 09:50:45 | daniel.urban | 创建 | |
|