Author: Armin Rigo <[email protected]>
Branch: remove-objspace-options
Changeset: r83853:9f7ebf38a251
Date: 2016-04-25 11:26 +0200
http://bitbucket.org/pypy/pypy/changeset/9f7ebf38a251/
Log: cleanups
diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -52,7 +52,7 @@
_, w_descr = w_type._lookup_where(name)
w_descr_cell = None
else:
- _, w_descr_cell =
w_type._pure_lookup_where_possibly_with_method_cache(
+ _, w_descr_cell = w_type._pure_lookup_where_with_method_cache(
name, version_tag)
w_descr = w_descr_cell
if isinstance(w_descr, MutableCell):
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -69,7 +69,7 @@
elif instance:
from pypy.objspace.std.mapdict import MapDictStrategy
strategy = space.fromcache(MapDictStrategy)
- elif instance or strdict or module:
+ elif strdict or module:
assert w_type is None
strategy = space.fromcache(BytesDictStrategy)
elif kwargs:
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -977,7 +977,7 @@
name = space.str_w(w_name)
# We need to care for obscure cases in which the w_descr is
# a MutableCell, which may change without changing the version_tag
- _, w_descr = w_type._pure_lookup_where_possibly_with_method_cache(
+ _, w_descr = w_type._pure_lookup_where_with_method_cache(
name, version_tag)
#
attrname, index = ("", INVALID)
diff --git a/pypy/objspace/std/test/test_listobject.py
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -432,6 +432,8 @@
class AppTestListObject(object):
+ spaceconfig = {"objspace.std.withliststrategies": True} # it's the default
+
def setup_class(cls):
import platform
import sys
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -1,3 +1,4 @@
+import weakref
from pypy.interpreter import gateway
from pypy.interpreter.baseobjspace import W_Root, SpaceCache
from pypy.interpreter.error import oefmt, OperationError
@@ -9,6 +10,7 @@
from rpython.rlib.jit import (promote, elidable_promote, we_are_jitted,
elidable, dont_look_inside, unroll_safe)
from rpython.rlib.objectmodel import current_object_addr_as_int, compute_hash
+from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib.rarithmetic import intmask, r_uint
class MutableCell(W_Root):
@@ -85,6 +87,10 @@
for i in range(len(self.lookup_where)):
self.lookup_where[i] = None_None
+class _Global(object):
+ weakref_warning_printed = False
+_global = _Global()
+
class Layout(object):
"""A Layout is attached to every W_TypeObject to represent the
@@ -372,6 +378,7 @@
@unroll_safe
def _lookup(w_self, key):
+ # nowadays, only called from ../../tool/ann_override.py
space = w_self.space
for w_class in w_self.mro_w:
w_value = w_class.getdictvalue(space, key)
@@ -381,7 +388,7 @@
@unroll_safe
def _lookup_where(w_self, key):
- # like lookup() but also returns the parent class in which the
+ # like _lookup() but also returns the parent class in which the
# attribute was found
space = w_self.space
for w_class in w_self.mro_w:
@@ -415,9 +422,6 @@
return w_class, w_value.unwrap_cell(space)
return tup_w # don't make a new tuple, reuse the old one
- def _pure_lookup_where_possibly_with_method_cache(w_self, name,
version_tag):
- return w_self._pure_lookup_where_with_method_cache(name, version_tag)
-
@elidable
def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
space = w_self.space
@@ -535,9 +539,15 @@
def add_subclass(w_self, w_subclass):
space = w_self.space
if not space.config.translation.rweakref:
- w_self.weak_subclasses.append(w_subclass) # not really weak, but
well
- return
- import weakref
+ # We don't have weakrefs! In this case, every class stores
+ # subclasses in a non-weak list. ALL CLASSES LEAK! To make
+ # the user aware of this annoying fact, print a warning.
+ if we_are_translated() and not _global.weakref_warning_printed:
+ from rpython.rlib import debug
+ debug.debug_print("Warning: no weakref support in this PyPy. "
+ "All user-defined classes will leak!")
+ _global.weakref_warning_printed = True
+
assert isinstance(w_subclass, W_TypeObject)
newref = weakref.ref(w_subclass)
for i in range(len(w_self.weak_subclasses)):
@@ -550,13 +560,6 @@
def remove_subclass(w_self, w_subclass):
space = w_self.space
- if not space.config.translation.rweakref:
- for i in range(len(w_self.weak_subclasses)):
- w_cls = w_self.weak_subclasses[i]
- if w_cls is w_subclass:
- del w_self.weak_subclasses[i]
- return
- return
for i in range(len(w_self.weak_subclasses)):
ref = w_self.weak_subclasses[i]
if ref() is w_subclass:
@@ -565,8 +568,6 @@
def get_subclasses(w_self):
space = w_self.space
- if not space.config.translation.rweakref:
- return w_self.weak_subclasses[:]
subclasses_w = []
for ref in w_self.weak_subclasses:
w_ob = ref()
diff --git a/rpython/rtyper/lltypesystem/rbuilder.py
b/rpython/rtyper/lltypesystem/rbuilder.py
--- a/rpython/rtyper/lltypesystem/rbuilder.py
+++ b/rpython/rtyper/lltypesystem/rbuilder.py
@@ -1,5 +1,5 @@
from rpython.rlib import rgc, jit
-from rpython.rlib.objectmodel import enforceargs
+from rpython.rlib.objectmodel import enforceargs, dont_inline, always_inline
from rpython.rlib.rarithmetic import ovfcheck, r_uint, intmask
from rpython.rtyper.debug import ll_assert
from rpython.rlib.unroll import unrolling_iterable
@@ -37,15 +37,6 @@
# ------------------------------------------------------------
-def dont_inline(func):
- func._dont_inline_ = True
- return func
-
-def always_inline(func):
- func._always_inline_ = True
- return func
-
-
STRINGPIECE = lltype.GcStruct('stringpiece',
('buf', lltype.Ptr(STR)),
('prev_piece', lltype.Ptr(lltype.GcForwardReference())))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit