[capi-sig]New pythoncapi GitHub organization and creation of a test suite for the Python C API
Hi,
To be able to work on a fork of CPython, I decided to create a new GitHub organization:
https://github.com/pythoncapi/
I didn't want to work on my personal fork of CPython (vstinner/cpython). The organization has a single member: me, but I invited Eric Snow, Barry Warsaw and Pablo Galindo. Tell me if you want to join!
I moved my documentation there, the source of https://pythoncapi.readthedocs.io/ website:
https://github.com/pythoncapi/pythoncapi/
And I just forked CPython:
https://github.com/pythoncapi/cpython
I will experiment to implement the new C API in this fork, to not bother the upstream CPython.
I started with a very simple change, replace PyTuple_GET_ITEM() macro with a function call. I also started to write unit tests:
https://github.com/pythoncapi/cpython/blob/pythoncapi/capi/tests/test_tuple....
I quickly experimented to write my own C unit test framework, but I'm not really satisfied of the "verbose" API. I'm looking at googletest and Check, does someone have an experience with a C unit test framework?
I don't wante to write unit tests with Cython, cffi or anything else, because I really need very thin control on everything.
Victor
(Follow-up)
So I started to write a test suite for the C API. I chose to write them using "Check", a C framework to write unit tests in C.
Check looks nice:
- use fork() on UNIX/BSD to catch crashes (signals) and implement timeout
- JUnit (XML) output
- Selection of test at runtime
- straighforward API, with a short "ck_" prefix on symbols
See: https://github.com/pythoncapi/cpython/blob/pythoncapi/capi_tests/test_tuple....
For the long term, I would like to no longer support borrowed references, so I wrote *two* new C APIs:
Py_NEWAPI_BORROWED_REF: replace macros with function calls (PyTuple_GET_ITEM() calls PyTuple_GetItem()). I also added PyTuple_GetItemRef() and PyTuple_SetItemRef() to this API: similar to PyTuple_GetItem()/PyTuple_SetItem(), but use a strong reference instead of a borrowed reference. This API should provide stable ABI for the long term.
Py_NEWAPI: Py_NEWAPI_BORROWED_REF without borrowed refererences, PyTuple_GetItem() and PyTuple_SetItem() are done. This API allows to experiment more optimization inside a Python runtime: the API tracks the object lifetime.
I added a test matrix for the 3 API:
- "full API": current/old Python 3.8 API
- new C API with borrowed references: Py_NEWAPI_BORROWED_REF
- new C API without borrowed reference: Py_NEWAPI
Victor
Le ven. 31 août 2018 à 10:31, Victor Stinner <vstinner@redhat.com> a écrit :
Hi,
To be able to work on a fork of CPython, I decided to create a new GitHub organization:
https://github.com/pythoncapi/
I didn't want to work on my personal fork of CPython (vstinner/cpython). The organization has a single member: me, but I invited Eric Snow, Barry Warsaw and Pablo Galindo. Tell me if you want to join!
I moved my documentation there, the source of https://pythoncapi.readthedocs.io/ website:
https://github.com/pythoncapi/pythoncapi/
And I just forked CPython:
https://github.com/pythoncapi/cpython
I will experiment to implement the new C API in this fork, to not bother the upstream CPython.
I started with a very simple change, replace PyTuple_GET_ITEM() macro with a function call. I also started to write unit tests:
https://github.com/pythoncapi/cpython/blob/pythoncapi/capi/tests/test_tuple....
I quickly experimented to write my own C unit test framework, but I'm not really satisfied of the "verbose" API. I'm looking at googletest and Check, does someone have an experience with a C unit test framework?
I don't wante to write unit tests with Cython, cffi or anything else, because I really need very thin control on everything.
Victor
On Aug 31, 2018, at 07:03, Victor Stinner <vstinner@redhat.com> wrote:
(Follow-up)
So I started to write a test suite for the C API. I chose to write them using "Check", a C framework to write unit tests in C.
For the long term, I would like to no longer support borrowed references, so I wrote *two* new C APIs:
Nice work Victor! I’m not sure the instructions work on macOS though. I brew installed check to get the library, but after doing the configure and makes, the process core dumps in capi_tests/ . I don’t have much time to look at this now, but maybe at the core sprint.
-Barry
On Fri, 31 Aug 2018 at 01:33 Victor Stinner <vstinner@redhat.com> wrote:
Hi,
To be able to work on a fork of CPython, I decided to create a new GitHub organization:
https://github.com/pythoncapi/
I didn't want to work on my personal fork of CPython (vstinner/cpython). The organization has a single member: me, but I invited Eric Snow, Barry Warsaw and Pablo Galindo. Tell me if you want to join!
Sure, why not!
I moved my documentation there, the source of https://pythoncapi.readthedocs.io/ website:
https://github.com/pythoncapi/pythoncapi/
And I just forked CPython:
https://github.com/pythoncapi/cpython
I will experiment to implement the new C API in this fork, to not bother the upstream CPython.
I started with a very simple change, replace PyTuple_GET_ITEM() macro with a function call. I also started to write unit tests:
https://github.com/pythoncapi/cpython/blob/pythoncapi/capi/tests/test_tuple....
I quickly experimented to write my own C unit test framework, but I'm not really satisfied of the "verbose" API. I'm looking at googletest and Check, does someone have an experience with a C unit test framework?
I have used Catch, but that's C++.
-Brett
I don't wanted to write unit tests with Cython, cffi or anything else, because I really need very thin control on everything.
Victor
capi-sig mailing list -- capi-sig@python.org To unsubscribe send an email to capi-sig-leave@python.org
Le sam. 1 sept. 2018 à 04:24, Brett Cannon <brett@python.org> a écrit :
Tell me if you want to join!
Sure, why not!
You are now invited.
By the way, there are now 2 repositories and I don't want to have to manage permissions per repository, so I created a new "pythoncapi" team which has write access to pythoncapi and cpython repositories. Maybe I made some mistakes when I chose permissions.
I quickly experimented to write my own C unit test framework, but I'm not really satisfied of the "verbose" API. I'm looking at googletest and Check, does someone have an experience with a C unit test framework?
I have used Catch, but that's C++.
A friend (who works for Google) told me about googletest but it seems to have multiple dependencies and designed for C++: https://github.com/google/googletest
In CPython, the C language is a first citizen, and people who attempted to use C++ had troubles in the CPython community. So I chose to follow the trend and use Check which seems to be written for C. Check looks simple but has nice features.
Victor
Le 03/09/2018 à 10:29, Victor Stinner a écrit :
Le sam. 1 sept. 2018 à 04:24, Brett Cannon <brett@python.org> a écrit :
Tell me if you want to join!
Sure, why not!
You are now invited.
By the way, there are now 2 repositories and I don't want to have to manage permissions per repository, so I created a new "pythoncapi" team which has write access to pythoncapi and cpython repositories. Maybe I made some mistakes when I chose permissions.
I quickly experimented to write my own C unit test framework, but I'm not really satisfied of the "verbose" API. I'm looking at googletest and Check, does someone have an experience with a C unit test framework?
I have used Catch, but that's C++.
A friend (who works for Google) told me about googletest but it seems to have multiple dependencies and designed for C++: https://github.com/google/googletest
I don't know Catch or Check, but googletest isn't terrific anyway. It's mostly a bunch of macros. It's a much less pleasant experience than Python's unittest.
Regards
Antoine.
participants (4)
-
Antoine Pitrou
-
Barry Warsaw
-
Brett Cannon
-
Victor Stinner