[Python-checkins] peps: Draft of PEP 399: Pure Python/C Accelerator Module Compatibiilty Requirements

Ezio Melotti ezio.melotti at gmail.com
Tue Apr 5 16:53:04 CEST 2011


Hi,

On 05/04/2011 2.37, brett.cannon wrote:
> http://hg.python.org/peps/rev/7b9a5b01b479
> changeset:   3855:7b9a5b01b479
> user:        Brett Cannon<brett at python.org>
> date:        Mon Apr 04 16:37:07 2011 -0700
> summary:
>    Draft of PEP 399: Pure Python/C Accelerator Module Compatibiilty Requirements
>
> files:
>    pep-0399.txt |  205 +++++++++++++++++++++++++++++++++++++++
>    1 files changed, 205 insertions(+), 0 deletions(-)
>
>
> diff --git a/pep-0399.txt b/pep-0399.txt
> new file mode 100644
> --- /dev/null
> +++ b/pep-0399.txt
> @@ -0,0 +1,205 @@
> +PEP: 399
> +Title: Pure Python/C Accelerator Module Compatibiilty Requirements
> +Version: $Revision: 88219 $
> +Last-Modified: $Date: 2011-01-27 13:47:00 -0800 (Thu, 27 Jan 2011) $
> +Author: Brett Cannon<brett at python.org>
> +Status: Draft
> +Type: Informational
> +Content-Type: text/x-rst
> +Created: 04-Apr-2011
> +Python-Version: 3.3
> +Post-History:
> +
> [...]
> +
> +Any accelerated code must be semantically identical to the pure Python
> +implementation. The only time any semantics are allowed to be
> +different are when technical details of the VM providing the
> +accelerated code prevent matching semantics from being possible, e.g.,
> +a class being a ``type`` when implemented in C. The semantics
> +equivalence requirement also dictates that no public API be provided
> +in accelerated code that does not exist in the pure Python code.
> +Without this requirement people could accidentally come to rely on a
> +detail in the acclerated code which is not made available to other VMs
s/acclerated/accelerated/
> +that use the pure Python implementation. To help verify that the
> +contract of semantic equivalence is being met, a module must be tested
> +both with and without its accelerated code as thoroughly as possible.
> +
> +As an example, to write tests which exercise both the pure Python and
> +C acclerated versions of a module, a basic idiom can be followed::
ditto
> +
> +    import collections.abc
> +    from test.support import import_fresh_module, run_unittest
> +    import unittest
> +
> +    c_heapq = import_fresh_module('heapq', fresh=['_heapq'])
> +    py_heapq = import_fresh_module('heapq', blocked=['_heapq'])
> +
> +
> +    class ExampleTest(unittest.TestCase):
> [...]
> +Copyright
> +=========
> +
> +This document has been placed in the public domain.
> +
> +
> +.. _IronPython: http://ironpython.net/
> +.. _Jython: http://www.jython.org/
> +.. _PyPy: http://pypy.org/
> +.. _C API of Python: http://docs.python.org/py3k/c-api/index.html
> +.. _sqlite3: http://docs.python.org/py3k/library/sqlite3.html
>
Best Regards,
Ezio Melotti


More information about the Python-checkins mailing list