classes.py.svn-base
来自「解码器是基于短语的统计机器翻译系统的核心模块」· SVN-BASE 代码 · 共 54 行
SVN-BASE
54 行
############################################################################ # Psyco class support module.# Copyright (C) 2001-2002 Armin Rigo et.al."""Psyco class support module.'psyco.classes.psyobj' is an alternate Psyco-optimized root for classes.Any class inheriting from it or using the metaclass '__metaclass__' mightget optimized specifically for Psyco. It is equivalent to callpsyco.bind() on the class object after its creation.Note that this module has no effect with Python version 2.1 or earlier.Importing everything from psyco.classes in a module will import the'__metaclass__' name, so all classes defined after a from psyco.classes import *will automatically use the Psyco-optimized metaclass."""###########################################################################__all__ = ['psyobj', 'psymetaclass', '__metaclass__']# Python version checktry: from _psyco import compacttypeexcept ImportError: class psyobj: # compatilibity pass psymetaclass = Noneelse: # version >= 2.2 only import core from types import FunctionType class psymetaclass(compacttype): "Psyco-optimized meta-class. Turns all methods into Psyco proxies." def __new__(cls, name, bases, dict): bindlist = dict.get('__psyco__bind__') if bindlist is None: bindlist = [key for key, value in dict.items() if isinstance(value, FunctionType)] for attr in bindlist: dict[attr] = core.proxy(dict[attr]) return super(psymetaclass, cls).__new__(cls, name, bases, dict) psyobj = psymetaclass("psyobj", (), {})__metaclass__ = psymetaclass
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?