This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lpd
Recipients arkanes, christian.heimes, gvanrossum, lpd, ntoronto
Date 2008-01-05.19:59:02
SpamBayes Score 0.031755652
Marked as misclassified No
Message-id <1199563144.42.0.327205473901.issue1518@psf.upfronthosting.co.za>
In-reply-to
Content
The proposed approach to speeding up lookup of inherited methods is not
quite sound, given that class attributes can be added and removed
dynamically. Consider:

class A:
  def f(x): ...
class B(A):
  pass
class C(B):
  pass

If C caches a pointer to A.f, the wrong thing will happen if B.f is
defined dynamically, even though C's pointer will still point to a valid
and up-to-date entry for f in A's dict, and C's MRO will not have changed.

I thought a sufficient fix would be for classes to increment not only
their own 64-bit dict "version" but that of all classes in their MRO if
an entry is ever added or removed in their dict. But even this is not
sufficient. Consider:

class A:
  def f(x): ...
class B(A):
  pass
class C(B):
  pass
class D:
  pass
class E(D,C):
  pass

If D.f is defined dynamically, E's cached pointer to C.f will retrieve
the wrong value. But C is not in D's MRO.

I haven't encountered this issue before in a system with multiple base
classes (my extensive experience is with classic Smalltalk, and
PostScript), so I don't have an off-the-cuff solution.
History
Date User Action Args
2008-01-05 19:59:04lpdsetspambayes_score: 0.0317557 -> 0.031755652
recipients: + lpd, gvanrossum, christian.heimes, arkanes, ntoronto
2008-01-05 19:59:04lpdsetspambayes_score: 0.0317557 -> 0.0317557
messageid: <1199563144.42.0.327205473901.issue1518@psf.upfronthosting.co.za>
2008-01-05 19:59:03lpdlinkissue1518 messages
2008-01-05 19:59:02lpdcreate