Commit 5406f1ea authored by Manuel Jacob's avatar Manuel Jacob

hg merge kill-multimethod

Kill multimethod machinery, all multimethods were removed earlier.
parents dee29de9 c70f94e3
......@@ -255,10 +255,6 @@ pypy_optiondescription = OptionDescription("objspace", "Object Space Options", [
BoolOption("optimized_list_getitem",
"special case the 'list[integer]' expressions",
default=False),
BoolOption("builtinshortcut",
"a shortcut for operations between built-in types. XXX: "
"deprecated, not really a shortcut any more.",
default=False),
BoolOption("getattributeshortcut",
"track types that override __getattribute__",
default=False,
......@@ -270,9 +266,6 @@ pypy_optiondescription = OptionDescription("objspace", "Object Space Options", [
# weakrefs needed, because of get_subclasses()
requires=[("translation.rweakref", True)]),
ChoiceOption("multimethods", "the multimethod implementation to use",
["doubledispatch", "mrd"],
default="mrd"),
BoolOption("withidentitydict",
"track types that override __hash__, __eq__ or __cmp__ and use a special dict strategy for those which do not",
default=False,
......
A shortcut speeding up primitive operations between built-in types.
This is a space-time trade-off: at the moment, this option makes a
translated pypy-c executable bigger by about 1.7 MB. (This can probably
be improved with careful analysis.)
Choose the multimethod implementation.
* ``doubledispatch`` turns
a multimethod call into a sequence of normal method calls.
* ``mrd`` uses a technique known as Multiple Row Displacement
which precomputes a few compact tables of numbers and
function pointers.
......@@ -208,23 +208,6 @@ class PyPyTarget(object):
from pypy.config.pypyoption import set_pypy_opt_level
set_pypy_opt_level(config, translateconfig.opt)
# as of revision 27081, multimethod.py uses the InstallerVersion1 by default
# because it is much faster both to initialize and run on top of CPython.
# The InstallerVersion2 is optimized for making a translator-friendly
# structure for low level backends. However, InstallerVersion1 is still
# preferable for high level backends, so we patch here.
from pypy.objspace.std import multimethod
if config.objspace.std.multimethods == 'mrd':
assert multimethod.InstallerVersion1.instance_counter == 0,\
'The wrong Installer version has already been instatiated'
multimethod.Installer = multimethod.InstallerVersion2
elif config.objspace.std.multimethods == 'doubledispatch':
# don't rely on the default, set again here
assert multimethod.InstallerVersion2.instance_counter == 0,\
'The wrong Installer version has already been instatiated'
multimethod.Installer = multimethod.InstallerVersion1
def print_help(self, config):
self.opt_parser(config).print_help()
......
......@@ -618,6 +618,7 @@ from pypy.interpreter.generator import GeneratorIterator
from pypy.interpreter.nestedscope import Cell
from pypy.interpreter.special import NotImplemented, Ellipsis
def descr_get_dict(space, w_obj):
w_dict = w_obj.getdict(space)
if w_dict is None:
......@@ -638,6 +639,11 @@ def descr_get_weakref(space, w_obj):
return space.w_None
return lifeline.get_any_weakref(space)
dict_descr = GetSetProperty(descr_get_dict, descr_set_dict, descr_del_dict,
doc="dictionary for instance variables (if defined)")
dict_descr.name = '__dict__'
def generic_ne(space, w_obj1, w_obj2):
if space.eq_w(w_obj1, w_obj2):
return space.w_False
......
......@@ -17,7 +17,6 @@ from pypy.interpreter.typedef import (
GetSetProperty, TypeDef, make_weakref_descr)
from pypy.interpreter.generator import GeneratorIterator
from pypy.module._file.interp_file import W_File
from pypy.objspace.std.floatobject import W_FloatObject
@unwrap_spec(typecode=str)
......@@ -654,7 +653,7 @@ def make_array(mytype):
try:
item = unwrap(w_item)
except OperationError, e:
if isinstance(w_item, W_FloatObject):
if space.isinstance_w(w_item, space.w_float):
# Odd special case from cpython
raise
if mytype.method != '' and e.match(space, space.w_TypeError):
......
......@@ -1035,8 +1035,3 @@ class AppTestArray(BaseArrayTests):
def test_fresh_array_buffer_str(self):
assert str(buffer(self.array('i'))) == ''
class AppTestArrayBuiltinShortcut(AppTestArray):
spaceconfig = AppTestArray.spaceconfig.copy()
spaceconfig['objspace.std.builtinshortcut'] = True
......@@ -303,11 +303,6 @@ class W_PyCTypeObject(W_TypeObject):
@bootstrap_function
def init_typeobject(space):
# Probably a hack
space.model.typeorder[W_PyCTypeObject] = [(W_PyCTypeObject, None),
(W_TypeObject, None),
(W_Root, None)]
make_typedescr(space.w_type.instancetypedef,
basestruct=PyTypeObject,
alloc=type_alloc,
......
......@@ -2,7 +2,6 @@ from rpython.annotator.model import SomeInstance, s_None
from pypy.interpreter import argument, gateway
from pypy.interpreter.baseobjspace import W_Root, ObjSpace, SpaceCache
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.sliceobject import W_SliceObject
from rpython.rlib.buffer import StringBuffer
from rpython.rlib.objectmodel import instantiate, we_are_translated, specialize
......@@ -112,6 +111,10 @@ class Entry(ExtRegistryEntry):
# ____________________________________________________________
BUILTIN_TYPES = ['int', 'str', 'float', 'long', 'tuple', 'list', 'dict',
'unicode', 'complex', 'slice', 'bool', 'basestring', 'object',
'bytearray', 'buffer']
class FakeObjSpace(ObjSpace):
def __init__(self, config=None):
self._seen_extras = []
......@@ -342,9 +345,7 @@ class FakeObjSpace(ObjSpace):
def setup(space):
for name in (ObjSpace.ConstantTable +
ObjSpace.ExceptionTable +
['int', 'str', 'float', 'long', 'tuple', 'list',
'dict', 'unicode', 'complex', 'slice', 'bool',
'basestring', 'object', 'bytearray', 'buffer']):
BUILTIN_TYPES):
setattr(space, 'w_' + name, w_some_obj())
space.w_type = w_some_type()
#
......@@ -375,7 +376,7 @@ class FakeObjSpace(ObjSpace):
@specialize.memo()
def see_typedef(space, typedef):
assert isinstance(typedef, TypeDef)
if not isinstance(typedef, StdTypeDef):
if typedef.name not in BUILTIN_TYPES:
for name, value in typedef.rawdict.items():
space.wrap(value)
......
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.interpreter.typedef import TypeDef
basestring_typedef = StdTypeDef("basestring",
basestring_typedef = TypeDef("basestring",
__doc__ = ("basestring cannot be instantiated; "
"it is the base for str and unicode.")
)
......@@ -6,8 +6,8 @@ from rpython.rlib.rarithmetic import r_uint
from rpython.tool.sourcetools import func_renamer, func_with_new_name
from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std.intobject import W_AbstractIntObject, W_IntObject
from pypy.objspace.std.stdtypedef import StdTypeDef
class W_BoolObject(W_IntObject):
......@@ -80,7 +80,7 @@ W_BoolObject.w_False = W_BoolObject(False)
W_BoolObject.w_True = W_BoolObject(True)
W_BoolObject.typedef = StdTypeDef("bool", W_IntObject.typedef,
W_BoolObject.typedef = TypeDef("bool", W_IntObject.typedef,
__doc__ = """bool(x) -> bool
Returns True when the argument x is true, False otherwise.
......
from pypy.interpreter.baseobjspace import ObjSpace
from pypy.interpreter.error import OperationError
from pypy.objspace.descroperation import DescrOperation
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.objspace.std.boolobject import W_BoolObject
from rpython.tool.sourcetools import func_with_new_name
# ____________________________________________________________
#
# The sole purpose of this file is performance.
# It speeds up the dispatch of operations between
# built-in objects.
#
# this is a selection... a few operations are missing because they are
# thought to be very rare or most commonly used with non-builtin types
METHODS_WITH_SHORTCUT = dict.fromkeys(
['add', 'sub', 'mul', 'truediv', 'floordiv', 'div',
'mod', 'lshift', 'rshift', 'and_', 'or_', 'xor', 'pow',
'lt', 'le', 'eq', 'ne', 'gt', 'ge', 'contains',
# unary
'len', 'nonzero', 'repr', 'str', 'hash',
'neg', 'invert', 'index', 'iter', 'next', 'buffer',
'getitem', 'setitem', 'int',
# in-place
'inplace_add', 'inplace_sub', 'inplace_mul', 'inplace_truediv',
'inplace_floordiv', 'inplace_div', 'inplace_mod', 'inplace_pow',
'inplace_lshift', 'inplace_rshift', 'inplace_and', 'inplace_or',
'inplace_xor',
# other
'format',
])
KNOWN_MISSING = ['getattr', # mostly non-builtins or optimized by CALL_METHOD
'setattr', 'delattr', 'userdel', # mostly for non-builtins
'get', 'set', 'delete', # uncommon (except on functions)
'getslice', 'setslice', 'delslice', # see below
'delitem', 'trunc', # rare stuff?
'abs', 'hex', 'oct', # rare stuff?
'pos', 'divmod', 'cmp', # rare stuff?
'float', 'long', 'coerce', # rare stuff?
'isinstance', 'issubtype',
]
# We cannot support {get,set,del}slice right now because
# DescrOperation.{get,set,del}slice do a bit more work than just call
# the special methods: they call old_slice_range(). See e.g.
# test_builtinshortcut.AppTestString.
for _name, _, _, _specialmethods in ObjSpace.MethodTable:
if _specialmethods:
assert _name in METHODS_WITH_SHORTCUT or _name in KNOWN_MISSING, (
"operation %r should be in METHODS_WITH_SHORTCUT or KNOWN_MISSING"
% (_name,))
def filter_out_conversions(typeorder):
res = {}
for cls, order in typeorder.iteritems():
res[cls] = [(target_type, converter) for (target_type, converter) in
order if converter is None]
return res
def install(space, mm, fallback_mm=None):
"""Install a function <name>() on the space instance which invokes
a shortcut for built-in types. Returns the shortcutting multimethod
object or None.
"""
name = mm.name
if name not in METHODS_WITH_SHORTCUT:
return None
# can be called multiple times without re-installing
if name in space.__dict__:
mm1, shortcut_method = space.__dict__[name].builtinshortcut
assert mm1 is mm
return shortcut_method
#print 'installing shortcut for:', name
assert hasattr(DescrOperation, name)
base_method = getattr(space.__class__, name)
# Basic idea: we first try to dispatch the operation using purely
# the multimethod. If this is done naively, subclassing a built-in
# type like 'int' and overriding a special method like '__add__'
# doesn't work any more, because the multimethod will accept the int
# subclass and compute the result in the built-in way. To avoid
# this issue, we tweak the shortcut multimethods so that these ones
# (and only these ones) never match the interp-level subclasses
# built in pypy.interpreter.typedef.get_unique_interplevel_subclass.
expanded_order = space.model.get_typeorder_with_empty_usersubcls()
if fallback_mm:
mm = mm.merge_with(fallback_mm)
shortcut_method = mm.install_not_sliced(filter_out_conversions(expanded_order))
def operate(*args_w):
try:
return shortcut_method(space, *args_w)
except FailedToImplement:
pass
return base_method(space, *args_w)
operate = func_with_new_name(operate, name)
operate.builtinshortcut = (mm, shortcut_method)
setattr(space, name, operate)
return shortcut_method
def install_is_true(space, mm_nonzero, mm_len):
shortcut = install(space, mm_nonzero, fallback_mm = mm_len)
assert 'is_true' not in space.__dict__
def is_true(w_obj):
# a bit of duplication of the logic from DescrOperation.is_true...
try:
w_res = shortcut(space, w_obj)
except FailedToImplement:
pass
else:
# the __nonzero__ method of built-in objects should
# always directly return a Bool; however, the __len__ method
# of built-in objects typically returns an unwrappable integer
if isinstance(w_res, W_BoolObject):
return bool(w_res.intval)
try:
return space.int_w(w_res) != 0
except OperationError:
# I think no OperationError other than w_OverflowError
# could occur here
w_obj = w_res
# general case fallback
return _DescrOperation_is_true(space, w_obj)
_DescrOperation_is_true = DescrOperation.is_true.im_func
space.is_true = is_true
......@@ -10,8 +10,8 @@ from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
from pypy.interpreter.signature import Signature
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std.sliceobject import W_SliceObject
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.stringmethods import StringMethods, _get_buffer
from pypy.objspace.std.bytesobject import W_BytesObject
from pypy.objspace.std.util import get_positive_index
......@@ -990,7 +990,7 @@ class BytearrayDocstrings:
"""
W_BytearrayObject.typedef = StdTypeDef(
W_BytearrayObject.typedef = TypeDef(
"bytearray",
__doc__ = BytearrayDocstrings.__doc__,
__new__ = interp2app(W_BytearrayObject.descr_new),
......
......@@ -10,10 +10,10 @@ from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import (
WrappedDefault, interp2app, interpindirect2app, unwrap_spec)
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std import newformat
from pypy.objspace.std.basestringtype import basestring_typedef
from pypy.objspace.std.formatting import mod_format
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.stringmethods import StringMethods
from pypy.objspace.std.unicodeobject import (
_get_encoding_and_errors, decode_object, unicode_from_encoded_object,
......@@ -874,7 +874,7 @@ def wrapchar(space, c):
return W_BytesObject(c)
W_BytesObject.typedef = StdTypeDef(
W_BytesObject.typedef = TypeDef(
"str", basestring_typedef,
__new__ = interp2app(W_BytesObject.descr_new),
__doc__ = """str(object='') -> string
......
......@@ -3,9 +3,9 @@ import math
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.interpreter.typedef import GetSetProperty, TypeDef
from pypy.objspace.std import newformat
from pypy.objspace.std.floatobject import _hash_float
from pypy.objspace.std.stdtypedef import GetSetProperty, StdTypeDef
from rpython.rlib import jit, rcomplex
from rpython.rlib.rarithmetic import intmask, r_ulonglong
from rpython.rlib.rbigint import rbigint
......@@ -264,7 +264,7 @@ class W_ComplexObject(W_Root):
if self.user_overridden_class:
return None
from rpython.rlib.longlong2float import float2longlong
from pypy.objspace.std.model import IDTAG_COMPLEX as tag
from pypy.objspace.std.util import IDTAG_COMPLEX as tag
real = space.float_w(space.getattr(self, space.wrap("real")))
imag = space.float_w(space.getattr(self, space.wrap("imag")))
real_b = rbigint.fromrarith_int(float2longlong(real))
......@@ -587,7 +587,7 @@ def complexwprop(name):
return space.newfloat(getattr(w_obj, name))
return GetSetProperty(fget)
W_ComplexObject.typedef = StdTypeDef("complex",
W_ComplexObject.typedef = TypeDef("complex",
__doc__ = """complex(real[, imag]) -> complex number
Create a complex number from a real part and an optional imaginary part.
......
......@@ -11,7 +11,7 @@ from pypy.interpreter.gateway import (
WrappedDefault, applevel, interp2app, unwrap_spec)
from pypy.interpreter.mixedmodule import MixedModule
from pypy.interpreter.signature import Signature
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std.util import negate
......@@ -372,7 +372,7 @@ app = applevel('''
dictrepr = app.interphook("dictrepr")
W_DictMultiObject.typedef = StdTypeDef("dict",
W_DictMultiObject.typedef = TypeDef("dict",
__doc__ = '''dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object\'s
(key, value) pairs.
......@@ -1217,8 +1217,6 @@ def characterize(space, w_a, w_b):
class W_BaseDictMultiIterObject(W_Root):
_immutable_fields_ = ["iteratorimplementation"]
ignore_for_isinstance_cache = True
def __init__(self, space, iteratorimplementation):
self.space = space
self.iteratorimplementation = iteratorimplementation
......@@ -1309,7 +1307,7 @@ class W_DictMultiIterItemsObject(W_BaseDictMultiIterObject):
return space.newtuple([w_key, w_value])
raise OperationError(space.w_StopIteration, space.w_None)
W_DictMultiIterItemsObject.typedef = StdTypeDef(
W_DictMultiIterItemsObject.typedef = TypeDef(
"dict_iteritems",
__iter__ = interp2app(W_DictMultiIterItemsObject.descr_iter),
next = interp2app(W_DictMultiIterItemsObject.descr_next),
......@@ -1317,7 +1315,7 @@ W_DictMultiIterItemsObject.typedef = StdTypeDef(
__reduce__ = interp2app(W_BaseDictMultiIterObject.descr_reduce),
)
W_DictMultiIterKeysObject.typedef = StdTypeDef(
W_DictMultiIterKeysObject.typedef = TypeDef(
"dict_iterkeys",
__iter__ = interp2app(W_DictMultiIterKeysObject.descr_iter),
next = interp2app(W_DictMultiIterKeysObject.descr_next),
......@@ -1325,7 +1323,7 @@ W_DictMultiIterKeysObject.typedef = StdTypeDef(
__reduce__ = interp2app(W_BaseDictMultiIterObject.descr_reduce),
)
W_DictMultiIterValuesObject.typedef = StdTypeDef(
W_DictMultiIterValuesObject.typedef = TypeDef(
"dict_itervalues",
__iter__ = interp2app(W_DictMultiIterValuesObject.descr_iter),
next = interp2app(W_DictMultiIterValuesObject.descr_next),
......@@ -1433,7 +1431,7 @@ class W_DictViewValuesObject(W_DictViewObject):
def descr_iter(self, space):
return W_DictMultiIterValuesObject(space, self.w_dict.itervalues())
W_DictViewItemsObject.typedef = StdTypeDef(
W_DictViewItemsObject.typedef = TypeDef(
"dict_items",
__repr__ = interp2app(W_DictViewItemsObject.descr_repr),
__len__ = interp2app(W_DictViewItemsObject.descr_len),
......@@ -1456,7 +1454,7 @@ W_DictViewItemsObject.typedef = StdTypeDef(
__rxor__ = interp2app(W_DictViewItemsObject.descr_rxor),
)
W_DictViewKeysObject.typedef = StdTypeDef(
W_DictViewKeysObject.typedef = TypeDef(
"dict_keys",
__repr__ = interp2app(W_DictViewKeysObject.descr_repr),
__len__ = interp2app(W_DictViewKeysObject.descr_len),
......@@ -1479,7 +1477,7 @@ W_DictViewKeysObject.typedef = StdTypeDef(
__rxor__ = interp2app(W_DictViewKeysObject.descr_rxor),
)
W_DictViewValuesObject.typedef = StdTypeDef(
W_DictViewValuesObject.typedef = TypeDef(
"dict_values",
__repr__ = interp2app(W_DictViewValuesObject.descr_repr),
__len__ = interp2app(W_DictViewValuesObject.descr_len),
......
......@@ -5,10 +5,9 @@ import sys
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
from pypy.interpreter.typedef import GetSetProperty
from pypy.interpreter.typedef import GetSetProperty, TypeDef
from pypy.objspace.std import newformat
from pypy.objspace.std.longobject import W_LongObject
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.util import wrap_parsestringerror
from rpython.rlib import rarithmetic, rfloat
from rpython.rlib.rarithmetic import ovfcheck_float_to_int, intmask, LONG_BIT
......@@ -182,7 +181,7 @@ class W_FloatObject(W_Root):
if self.user_overridden_class:
return None
from rpython.rlib.longlong2float import float2longlong
from pypy.objspace.std.model import IDTAG_FLOAT as tag
from pypy.objspace.std.util import IDTAG_FLOAT as tag
val = float2longlong(space.float_w(self))
b = rbigint.fromrarith_int(val)
b = b.lshift(3).or_(rbigint.fromint(tag))
......@@ -646,7 +645,7 @@ class W_FloatObject(W_Root):
return space.wrap("0x%sp%s%d" % (s, sign, exp))
W_FloatObject.typedef = StdTypeDef("float",
W_FloatObject.typedef = TypeDef("float",
__doc__ = '''float(x) -> floating point number
Convert a string or number to a floating point number, if possible.''',
......
......@@ -21,11 +21,10 @@ from pypy.interpreter import typedef
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std import newformat
from pypy.objspace.std.model import (
BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_INT)
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.util import wrap_parsestringerror
from pypy.objspace.std.util import (
BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_INT, wrap_parsestringerror)
SENTINEL = object()
......@@ -601,6 +600,16 @@ class W_IntObject(W_AbstractIntObject):
_divmod, ovf2small=_divmod_ovf2small)
def setup_prebuilt(space):
if space.config.objspace.std.withprebuiltint:
W_IntObject.PREBUILT = []
for i in range(space.config.objspace.std.prebuiltintfrom,
space.config.objspace.std.prebuiltintto):
W_IntObject.PREBUILT.append(W_IntObject(i))
else:
W_IntObject.PREBUILT = None
def wrapint(space, x):
if not space.config.objspace.std.withprebuiltint:
return W_IntObject(x)
......@@ -723,7 +732,7 @@ def _new_int(space, w_inttype, w_x, w_base=None):
return w_obj
W_IntObject.typedef = StdTypeDef("int",
W_IntObject.typedef = TypeDef("int",
__doc__ = """int(x=0) -> int or long
int(x, base=10) -> int or long
......
......@@ -3,7 +3,7 @@
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.gateway import interp2app, interpindirect2app
from pypy.interpreter.error import OperationError
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.interpreter.typedef import TypeDef
class W_AbstractSeqIterObject(W_Root):
......@@ -40,7 +40,7 @@ class W_AbstractSeqIterObject(W_Root):
def descr_length_hint(self, space):
return self.getlength(space)
W_AbstractSeqIterObject.typedef = StdTypeDef(
W_AbstractSeqIterObject.typedef = TypeDef(
"sequenceiterator",
__doc__ = '''iter(collection) -> iterator
iter(callable, sentinel) -> iterator
......@@ -159,7 +159,7 @@ class W_ReverseSeqIterObject(W_Root):
raise OperationError(space.w_StopIteration, space.w_None)
return w_item
W_ReverseSeqIterObject.typedef = StdTypeDef(
W_ReverseSeqIterObject.typedef = TypeDef(
"reversesequenceiterator",
__iter__ = interp2app(W_ReverseSeqIterObject.descr_iter),
next = interp2app(W_ReverseSeqIterObject.descr_next),
......
......@@ -16,6 +16,7 @@ from pypy.interpreter.gateway import (WrappedDefault, unwrap_spec, applevel,
interp2app)
from pypy.interpreter.generator import GeneratorIterator
from pypy.interpreter.signature import Signature
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std.bytesobject import W_BytesObject
from pypy.objspace.std.floatobject import W_FloatObject
from pypy.objspace.std.intobject import W_IntObject
......@@ -23,7 +24,6 @@ from pypy.objspace.std.iterobject import (W_FastListIterObject,
W_ReverseSeqIterObject)
from pypy.objspace.std.sliceobject import (W_SliceObject, unwrap_start_stop,
normalize_simple_slice)
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.tupleobject import W_AbstractTupleObject
from pypy.objspace.std.unicodeobject import W_UnicodeObject
from pypy.objspace.std.util import get_positive_index, negate
......@@ -1830,7 +1830,7 @@ class CustomKeyCompareSort(CustomCompareSort):
return CustomCompareSort.lt(self, a.w_key, b.w_key)
W_ListObject.typedef = StdTypeDef("list",
W_ListObject.typedef = TypeDef("list",
__doc__ = """list() -> new empty list
list(iterable) -> new list initialized from iterable's items""",
__new__ = interp2app(W_ListObject.descr_new),
......
......@@ -12,12 +12,11 @@ from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import (
WrappedDefault, interp2app, interpindirect2app, unwrap_spec)
from pypy.interpreter.typedef import TypeDef
from pypy.objspace.std import newformat
from pypy.objspace.std.intobject import W_AbstractIntObject
from pypy.objspace.std.model import (
BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_LONG)
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.objspace.std.util import wrap_parsestringerror
from pypy.objspace.std.util import (
BINARY_OPS, CMP_OPS, COMMUTATIVE_OPS, IDTAG_LONG, wrap_parsestringerror)
def delegate_other(func):
......@@ -567,7 +566,7 @@ def newbigint(space, w_longtype, bigint):
return w_obj
W_AbstractLongObject.typedef = StdTypeDef("long",
W_AbstractLongObject.typedef = TypeDef("long",
__doc__ = """long(x=0) -> long
long(x, base=10) -> long
......
This diff is collapsed.
This diff is collapsed.
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.gateway import interp2app
from pypy.objspace.std.stdtypedef import StdTypeDef
from pypy.interpreter.typedef import TypeDef
class W_NoneObject(W_Root):
......@@ -16,7 +16,7 @@ class W_NoneObject(W_Root):
W_NoneObject.w_None = W_NoneObject()
W_NoneObject.typedef = StdTypeDef("NoneType",
W_NoneObject.typedef = TypeDef("NoneType",
__nonzero__ = interp2app(W_NoneObject.descr_nonzero),
__repr__ = interp2app(W_NoneObject.descr_repr),
)
......
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import applevel, interp2app, unwrap_spec
from pypy.interpreter.typedef import GetSetProperty, default_identity_hash
from pypy.interpreter.typedef import GetSetProperty, default_identity_hash, TypeDef
from pypy.objspace.descroperation import Object
from pypy.objspace.std.stdtypedef import StdTypeDef
app = applevel(r'''
......@@ -211,7 +210,7 @@ def descr___format__(space, w_obj, w_format_spec):
return space.format(w_as_str, w_format_spec)
W_ObjectObject.typedef = StdTypeDef("object",
W_ObjectObject.typedef = TypeDef("object",
__doc__ = "The most base type",
__new__ = interp2app(descr__new__),
__subclasshook__ = interp2app(descr___subclasshook__, as_classmethod=True),
......
This diff is collapsed.
""" Some transparent helpers, put here because
of cyclic imports
"""
from pypy.objspace.std.model import W_ANY
from pypy.interpreter.argument import Arguments
from rpython.tool.sourcetools import func_with_new_name
def create_mm_names(classname, mm, is_local):
s = ""
if is_local:
s += "list_"
s += mm.name + "__"
s += "_".join([classname] + ["ANY"] * (mm.arity - 1))
#if '__' + mm.name + '__' in mm.specialnames:
# return s, '__' + mm.name + '__'
if mm.specialnames:
return s, mm.specialnames[0]
return s, mm.name
def install_general_args_trampoline(type_, mm, is_local, op_name):
def function(space, w_transparent_list, __args__):
args = __args__.prepend(space.wrap(op_name))
return space.call_args(w_transparent_list.w_controller, args)
function = func_with_new_name(function, mm.name)
mm.register(function, type_)
def install_args_w_trampoline(type_, mm, is_local, op_name):
def function(space, w_transparent_list, *args_w):
args = Arguments(space, [space.wrap(op_name)] + list(