Rev 66: 64 bit port. in http://people.canonical.com/~robertc/baz2.0/py_memory_dump

Robert Collins robertc at robertcollins.net
Thu Sep 10 22:14:25 BST 2009


At http://people.canonical.com/~robertc/baz2.0/py_memory_dump

------------------------------------------------------------
revno: 66
revision-id: robertc at robertcollins.net-20090910211403-971sixmm7fuwkr5h
parent: john at arbash-meinel.com-20090908171916-ekr6d1c8gb0e0eih
committer: Robert Collins <robertc at robertcollins.net>
branch nick: py_memory_dump
timestamp: Fri 2009-09-11 07:14:03 +1000
message:
  64 bit port.
=== added file 'Makefile'
--- a/Makefile	1970-01-01 00:00:00 +0000
+++ b/Makefile	2009-09-10 21:14:03 +0000
@@ -0,0 +1,9 @@
+all: build_inplace
+
+check:
+	python run_tests.py
+
+build_inplace:
+	python setup.py build_ext -i
+
+.PHONY: all build_inplace

=== modified file 'meliae/_scanner_core.c'
--- a/meliae/_scanner_core.c	2009-09-08 17:06:14 +0000
+++ b/meliae/_scanner_core.c	2009-09-10 21:14:03 +0000
@@ -258,7 +258,7 @@
     size = _size_of(c_obj);
     fprintf(out, "{\"address\": %lu, \"type\": ", (unsigned long)c_obj);
     _dump_json_c_string(out, c_obj->ob_type->tp_name, -1);
-    fprintf(out, ", \"size\": %d", _size_of(c_obj));
+    fprintf(out, ", \"size\": %ld", _size_of(c_obj));
     //  HANDLE __name__
     if (PyModule_Check(c_obj)) {
         fprintf(out, ", \"name\": ");
@@ -275,23 +275,23 @@
         _dump_string(out, ((PyClassObject *)c_obj)->cl_name);
     }
     if (PyString_Check(c_obj)) {
-        fprintf(out, ", \"len\": %d", PyString_GET_SIZE(c_obj));
+        fprintf(out, ", \"len\": %ld", PyString_GET_SIZE(c_obj));
         fprintf(out, ", \"value\": ");
         _dump_string(out, c_obj);
     } else if (PyUnicode_Check(c_obj)) {
-        fprintf(out, ", \"len\": %d", PyUnicode_GET_SIZE(c_obj));
+        fprintf(out, ", \"len\": %ld", PyUnicode_GET_SIZE(c_obj));
         fprintf(out, ", \"value\": ");
         _dump_unicode(out, c_obj);
     } else if (PyInt_CheckExact(c_obj)) {
         fprintf(out, ", \"value\": %ld", PyInt_AS_LONG(c_obj));
     } else if (PyTuple_Check(c_obj)) {
-        fprintf(out, ", \"len\": %d", PyTuple_GET_SIZE(c_obj));
+        fprintf(out, ", \"len\": %ld", PyTuple_GET_SIZE(c_obj));
     } else if (PyList_Check(c_obj)) {
-        fprintf(out, ", \"len\": %d", PyList_GET_SIZE(c_obj));
+        fprintf(out, ", \"len\": %ld", PyList_GET_SIZE(c_obj));
     } else if (PyAnySet_Check(c_obj)) {
-        fprintf(out, ", \"len\": %d", PySet_GET_SIZE(c_obj));
+        fprintf(out, ", \"len\": %ld", PySet_GET_SIZE(c_obj));
     } else if (PyDict_Check(c_obj)) {
-        fprintf(out, ", \"len\": %d", PyDict_Size(c_obj));
+        fprintf(out, ", \"len\": %ld", PyDict_Size(c_obj));
     }
     fprintf(out, ", \"refs\": [");
     if (c_obj->ob_type->tp_traverse != NULL) {

=== modified file 'meliae/tests/test__scanner.py'
--- a/meliae/tests/test__scanner.py	2009-09-08 17:19:16 +0000
+++ b/meliae/tests/test__scanner.py	2009-09-10 21:14:03 +0000
@@ -26,6 +26,11 @@
     tests,
     )
 
+
+STRING_BASE = 8
+STRING_SCALING = 4
+
+
 class TestSizeOf(tests.TestCase):
 
     def assertSizeOf(self, num_words, obj, extra_size=0, has_gc=True):
@@ -35,14 +40,14 @@
         self.assertEqual(expected_size, _scanner.size_of(obj))
 
     def test_empty_string(self):
-        self.assertSizeOf(6, '', extra_size=0, has_gc=False)
+        self.assertSizeOf(STRING_SCALING, '', extra_size=0+STRING_BASE, has_gc=False)
 
     def test_short_string(self):
-        self.assertSizeOf(6, 'a', extra_size=1, has_gc=False)
+        self.assertSizeOf(STRING_SCALING, 'a', extra_size=1+STRING_BASE, has_gc=False)
 
     def test_long_string(self):
-        self.assertSizeOf(6, ('abcd'*25)*1024,
-                          extra_size=100*1024, has_gc=False)
+        self.assertSizeOf(STRING_SCALING, ('abcd'*25)*1024,
+                          extra_size=100*1024+STRING_BASE, has_gc=False)
 
     def test_tuple(self):
         self.assertSizeOf(3, ())




More information about the bazaar-commits mailing list