Re: [Python-Dev] [Python-checkins] cpython (merge 3.2 - default): MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct
On Mon, Jul 23, 2012 at 11:17 AM, jesus.cea python-check...@python.org wrote: http://hg.python.org/cpython/rev/b9a3ed1b14b9 changeset: 78260:b9a3ed1b14b9 parent: 78257:03063e718f5f parent: 78259:1911e192af0d user:Jesus Cea j...@jcea.es date:Mon Jul 23 18:16:18 2012 +0200 summary: MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct files: Doc/ACKS.txt| 1 + Lib/test/test_struct.py | 8 2 files changed, 5 insertions(+), 4 deletions(-) Jesús, Doc/ACKS.txt is *only* for acknowledging documentation contributions. Serhiy is already in Misc/ACKS. No need to add him to Doc/ACKS.txt. As for the tests, I intentionally kept them the way that Serhiy contributed them -- using = instead of . I kept them this way because we also discussed in issue14596 the prospect of optimizing the way repeat counts are handled. These tests would start failing if (when) that optimization happens. So, neither of these changes are really necessary. Although, it wouldn't hurt to have *additional* tests using the relation. diff --git a/Doc/ACKS.txt b/Doc/ACKS.txt --- a/Doc/ACKS.txt +++ b/Doc/ACKS.txt @@ -205,6 +205,7 @@ * Anthony Starks * Greg Stein * Peter Stoehr + * Serhiy Storchaka * Mark Summerfield * Reuben Sumner * Kalle Svensson diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -575,12 +575,12 @@ def test_sizeof(self): self.assertGreater(sys.getsizeof(struct.Struct('BHILfdspP')), sys.getsizeof(struct.Struct('B'))) -self.assertGreaterEqual(sys.getsizeof(struct.Struct('123B')), +self.assertGreater(sys.getsizeof(struct.Struct('123B')), sys.getsizeof(struct.Struct('B'))) -self.assertGreaterEqual(sys.getsizeof(struct.Struct('B' * 123)), +self.assertGreater(sys.getsizeof(struct.Struct('B' * 1234)), sys.getsizeof(struct.Struct('123B'))) -self.assertGreaterEqual(sys.getsizeof(struct.Struct('123xB')), -sys.getsizeof(struct.Struct('B'))) +self.assertGreater(sys.getsizeof(struct.Struct('1234B')), +sys.getsizeof(struct.Struct('123B'))) def test_main(): run_unittest(StructTest) -- Repository URL: http://hg.python.org/cpython ___ Python-checkins mailing list python-check...@python.org http://mail.python.org/mailman/listinfo/python-checkins -- # Meador ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-checkins] cpython (merge 3.2 - default): MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 23/07/12 18:27, Meador Inge wrote: Doc/ACKS.txt is *only* for acknowledging documentation contributions. Serhiy is already in Misc/ACKS. No need to add him to Doc/ACKS.txt. Oh, I missed that. Thanks for the head up. As for the tests, I intentionally kept them the way that Serhiy contributed them -- using = instead of . I kept them this way because we also discussed in issue14596 the prospect of optimizing the way repeat counts are handled. These tests would start failing if (when) that optimization happens. The problem is that if we do =, then an unpatched python interpreter could pass the test too. So we are not actually testing the feature. If the repeat counters are going to be optimized, the obvious step would be to upgrade the test to do something like BHHIL instead of 123B. I would wait until this feature is implemented to update the test. What do you think?. So, neither of these changes are really necessary. Although, it wouldn't hurt to have *additional* tests using the relation. diff --git a/Doc/ACKS.txt b/Doc/ACKS.txt --- a/Doc/ACKS.txt +++ b/Doc/ACKS.txt @@ -205,6 +205,7 @@ * Anthony Starks * Greg Stein * Peter Stoehr + * Serhiy Storchaka * Mark Summerfield * Reuben Sumner * Kalle Svensson diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -575,12 +575,12 @@ def test_sizeof(self): self.assertGreater(sys.getsizeof(struct.Struct('BHILfdspP')), sys.getsizeof(struct.Struct('B'))) - self.assertGreaterEqual(sys.getsizeof(struct.Struct('123B')), + self.assertGreater(sys.getsizeof(struct.Struct('123B')), sys.getsizeof(struct.Struct('B'))) - self.assertGreaterEqual(sys.getsizeof(struct.Struct('B' * 123)), +self.assertGreater(sys.getsizeof(struct.Struct('B' * 1234)), sys.getsizeof(struct.Struct('123B'))) - self.assertGreaterEqual(sys.getsizeof(struct.Struct('123xB')), - sys.getsizeof(struct.Struct('B'))) + self.assertGreater(sys.getsizeof(struct.Struct('1234B')), + sys.getsizeof(struct.Struct('123B'))) def test_main(): run_unittest(StructTest) -- Repository URL: http://hg.python.org/cpython ___ Python-checkins mailing list python-check...@python.org http://mail.python.org/mailman/listinfo/python-checkins - -- Jesus Cea Avion _/_/ _/_/_/_/_/_/ j...@jcea.es - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ jabber / xmpp:j...@jabber.org _/_/_/_/ _/_/_/_/_/ . _/_/ _/_/_/_/ _/_/ _/_/ Things are not so easy _/_/ _/_/_/_/ _/_/_/_/ _/_/ My name is Dump, Core Dump _/_/_/_/_/_/ _/_/ _/_/ El amor es poner tu felicidad en la felicidad de otro - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQCVAwUBUA1+Bplgi5GaxT1NAQJtSAQAkv5DyoQ1N1YdOH2QLHnFbOsvp/1aG0Vy hHMlD6cu/L7Ub+gyWWo65v9Dp4sLahV+CYem1wL4Fzd2QyBNQdg+BNou9eqoDzGF IJbY2HALwOwz1vgeBiamFOSvpyWya/hzXR9I7rkBqXdR9c2Njdl/ioZQNKETO05k TRfd/BQas4k= =TKFO -END PGP SIGNATURE- ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-checkins] cpython (merge 3.2 - default): MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct
On Mon, Jul 23, 2012 at 11:38 AM, Jesus Cea j...@jcea.es wrote: As for the tests, I intentionally kept them the way that Serhiy contributed them -- using = instead of . I kept them this way because we also discussed in issue14596 the prospect of optimizing the way repeat counts are handled. These tests would start failing if (when) that optimization happens. The problem is that if we do =, then an unpatched python interpreter could pass the test too. So we are not actually testing the feature. We are testing the feature because the first test looks like: self.assertGreater(sys.getsizeof(struct.Struct('BHILfdspP')), sys.getsizeof(struct.Struct('B'))) The way things were written 'sys.getsizeof' would returns the same answer regardless of the format string. The remaining tests looked like: self.assertGreaterEqual(sys.getsizeof(struct.Struct('123B')), sys.getsizeof(struct.Struct('B'))) self.assertGreaterEqual(sys.getsizeof(struct.Struct('B' * 123)), sys.getsizeof(struct.Struct('123B'))) self.assertGreaterEqual(sys.getsizeof(struct.Struct('123xB')), sys.getsizeof(struct.Struct('B'))) and while they didn't fail without the patch I felt they were still useful in documenting that there is nothing that guarantees 'sizeof(123B) sizeof(B)' 'sizeof(B * 123) sizeof(123B)', or 'sizeof(123xB) sizeof(B)'. If the repeat counters are going to be optimized, the obvious step would be to upgrade the test to do something like BHHIL instead of 123B. I would wait until this feature is implemented to update the test. That is what the first test basically already does :-) What do you think?. It isn't that big of a deal. We can just leave the tests as you changed them. In the future it would probably be better to hash this stuff out in the tracker. The patch was out for review for several days ... Thanks, -- Meador ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-checkins] cpython (merge 3.2 - default): MERGE: Better test for Issue #15402: Add a __sizeof__ method to struct.Struct
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 23/07/12 20:19, Meador Inge wrote: self.assertGreaterEqual(sys.getsizeof(struct.Struct('123B')), [...] and while they didn't fail without the patch I felt they were still useful in documenting that there is nothing that guarantees 'sizeof(123B) sizeof(B)' 'sizeof(B * 123) sizeof(123B)', or 'sizeof(123xB) sizeof(B)'. No garantee, but I would find interesting that sizeof(1234B)==sizeof(B). If someday we implement some clever idea here (like the repeat counter optimization discussed), we can simply change sizeof(123B) to sizeof(12345B), or to sizeof(BHBHBHBH), etc. It isn't that big of a deal. We can just leave the tests as you changed them. In the future it would probably be better to hash this stuff out in the tracker. The patch was out for review for several days ... I agree. I should have raised this issue in the tracker. The fact is that I was checking the patch carefully today, when we collided mid-air working in the same issue both of us :-). I disliked the proposed tests at that time. Thanks for raising the issue. I will try to be more careful. - -- Jesus Cea Avion _/_/ _/_/_/_/_/_/ j...@jcea.es - http://www.jcea.es/ _/_/_/_/ _/_/_/_/ _/_/ jabber / xmpp:j...@jabber.org _/_/_/_/ _/_/_/_/_/ . _/_/ _/_/_/_/ _/_/ _/_/ Things are not so easy _/_/ _/_/_/_/ _/_/_/_/ _/_/ My name is Dump, Core Dump _/_/_/_/_/_/ _/_/ _/_/ El amor es poner tu felicidad en la felicidad de otro - Leibniz -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQCVAwUBUA2ZiZlgi5GaxT1NAQKwLQP/RqrP5qbvUtZ9MCuyTaT45l8+7QzqlJrx Nyh2t98jWVxiso0FDyT2vw839lX0CwssuKyNPFkXzKicNiX4mW0rC1uxNajCk0kG aVHKL6aC+65iJhA7+9uOW1yfRFyhqQbUc3aRlvg7UJMj4YEfB82Okk/2Wu0hgyiU 4Ti5VvFuOZ8= =G/WJ -END PGP SIGNATURE- ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com