Skip to content

Commit a9d99da

Browse files
committed
PickleBuffer AC vectorcall
1 parent 1cc5802 commit a9d99da

2 files changed

Lines changed: 80 additions & 11 deletions

File tree

‎Objects/clinic/picklebufobject.c.h‎

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Objects/picklebufobject.c‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS()
55
#include <stddef.h>
66

7+
#include "clinic/picklebufobject.c.h"
8+
9+
/*[clinic input]
10+
module pickle
11+
[clinic start generated code]*/
12+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6165c351cde067ba]*/
13+
14+
/*[clinic input]
15+
class pickle.PickleBuffer "PyPickleBufferObject *" "&PyPickleBuffer_Type"
16+
[clinic start generated code]*/
17+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b334ecd891c9cbc2]*/
18+
719
typedef struct {
820
PyObject_HEAD
921
/* The view exported by the original object */
@@ -66,19 +78,20 @@ PyPickleBuffer_Release(PyObject *obj)
6678
return 0;
6779
}
6880

69-
static PyObject *
70-
picklebuf_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
71-
{
72-
PyPickleBufferObject *self;
73-
PyObject *base;
74-
char *keywords[] = {"", NULL};
81+
/*[clinic input]
82+
@vectorcall
83+
@classmethod
84+
pickle.PickleBuffer.__new__ as picklebuf_new
7585
76-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:PickleBuffer",
77-
keywords, &base)) {
78-
return NULL;
79-
}
86+
base: object
87+
/
88+
[clinic start generated code]*/
8089

81-
self = (PyPickleBufferObject *) type->tp_alloc(type, 0);
90+
static PyObject *
91+
picklebuf_new_impl(PyTypeObject *type, PyObject *base)
92+
/*[clinic end generated code: output=b8269110aace6998 input=0f1cdf375a70e71d]*/
93+
{
94+
PyPickleBufferObject *self = (PyPickleBufferObject *) type->tp_alloc(type, 0);
8295
if (self == NULL) {
8396
return NULL;
8497
}
@@ -215,6 +228,7 @@ PyTypeObject PyPickleBuffer_Type = {
215228
.tp_basicsize = sizeof(PyPickleBufferObject),
216229
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
217230
.tp_new = picklebuf_new,
231+
.tp_vectorcall = picklebuf_vectorcall,
218232
.tp_dealloc = picklebuf_dealloc,
219233
.tp_traverse = picklebuf_traverse,
220234
.tp_clear = picklebuf_clear,

0 commit comments

Comments
 (0)