Author: Armin Rigo <[email protected]>
Branch: array-overallocation-in-nursery
Changeset: r67497:c2edf6cd836f
Date: 2013-10-22 11:50 +0200
http://bitbucket.org/pypy/pypy/changeset/c2edf6cd836f/

Log:    (fijal, arigo) _example()

diff --git a/rpython/rtyper/lltypesystem/lltype.py 
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1682,7 +1682,10 @@
             raise ValueError, "negative array length"
         _parentable.__init__(self, TYPE)
         if TYPE._is_overallocated_array():
-            self.used_len = 0
+            if initialization == 'example':
+                self.used_len = n
+            else:
+                self.used_len = 0
         myrange = self._check_range(n)
         self.items = [TYPE.OF._allocate(initialization=initialization,
                                         parent=self, parentindex=j)
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py 
b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -827,6 +827,9 @@
     a[0] = 100
     a[3] = 200
     assert repr(a) == '<* array allocated=10 [ 100, #, #, 200, # ]>'
+    #
+    b = Ptr(A)._example()
+    assert repr(b) == '<* array allocated=1 [ 0 ]>'
 
 class TestTrackAllocation:
     def test_automatic_tracking(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to