Python 2.7: inconsistency in "Extending Python with C or C++" example code
Hi! I wonder the meaningfulness of the inconsistency in the example code in: http://docs.python.org/extending/extending.html#intermezzo-errors-and-except... in chapters 1.1 and 1.3 the example code has: return Py_BuildValue("i", sts); whereas chapter 1.2 example code has: return PyLong_FromLong(sts); Best Regards, Jani 'Pöppis' Poikela
On Fri, Nov 12, 2010 at 2:27 PM, Jani Poikela <poppis.poikela@gmail.com> wrote:
in chapters 1.1 and 1.3 the example code has: return Py_BuildValue("i", sts); whereas chapter 1.2 example code has: return PyLong_FromLong(sts);
I suspect this is simply style changing over time. My own preference is to use PyLong_FromLong(...), since that executes slightly less code than the Py_BuildValue(...) approach, and I find it more readable as well. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> "A storm broke loose in my mind." --Albert Einstein
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 22.11.2010 05:24, schrieb Fred Drake:
On Fri, Nov 12, 2010 at 2:27 PM, Jani Poikela <poppis.poikela@gmail.com> wrote:
in chapters 1.1 and 1.3 the example code has: return Py_BuildValue("i", sts); whereas chapter 1.2 example code has: return PyLong_FromLong(sts);
I suspect this is simply style changing over time. My own preference is to use PyLong_FromLong(...), since that executes slightly less code than the Py_BuildValue(...) approach, and I find it more readable as well.
I've now put in PyLong_FromLong everywhere. Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEARECAAYFAkzvoGEACgkQN9GcIYhpnLDVegCfSmYR0up2irnX2ojt6Ct5m2SR /2QAoJN53j2NTapTNbtTEGu7DFdpRUiE =+3C7 -----END PGP SIGNATURE-----
participants (3)
-
Fred Drake -
Georg Brandl -
Jani Poikela