当然,如果类层次结构发生变化,并且出现另外的目标方法,则JIT编译器可以更正最初生成的代码以便执行虚调用。
Of course, if the class hierarchy changes and a second target method becomes possible, then the JIT compiler can correct the originally generated code so that the virtual invocation is performed.
研究表明:大多数虚调用只有一个目标对应于所有的接收方对象,而JIT编译器可以为直接调用生成比虚调用更有效率的代码。
Research has shown that most virtual invocations have only a single target for all receiver objects, and JIT compilers can generate more-efficient code for a direct call than for a virtual invocation.
Widget(所有pygtk部件的基类)的一些foo方法在内部调用虚方法do_foo。
Several foo methods of gtk.Widget (the base class for all PyGTK widgets) internally call the virtual methods do_foo.
应用推荐