Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(178858)

Delta Between Two Patch Sets: Modules/_pickle.c

Issue 27809: _PyObject_FastCall(): add support for keyword arguments
Left Patch Set: Created 2 years, 11 months ago
Right Patch Set: Created 2 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/_functoolsmodule.c ('k') | Modules/_sre.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 #include "Python.h" 1 #include "Python.h"
2 #include "structmember.h" 2 #include "structmember.h"
3 3
4 PyDoc_STRVAR(pickle_module_doc, 4 PyDoc_STRVAR(pickle_module_doc,
5 "Optimized C implementation for the Python pickle module."); 5 "Optimized C implementation for the Python pickle module.");
6 6
7 /*[clinic input] 7 /*[clinic input]
8 module _pickle 8 module _pickle
9 class _pickle.Pickler "PicklerObject *" "&Pickler_Type" 9 class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
10 class _pickle.PicklerMemoProxy "PicklerMemoProxyObject *" "&PicklerMemoProxyType " 10 class _pickle.PicklerMemoProxy "PicklerMemoProxyObject *" "&PicklerMemoProxyType "
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 a slight performance boost with older pickle implementations where many 350 a slight performance boost with older pickle implementations where many
351 unbuffered reads occurred (thus needing many function calls). 351 unbuffered reads occurred (thus needing many function calls).
352 352
353 However, this optimization was removed because it was too complicated 353 However, this optimization was removed because it was too complicated
354 to get right. It abused the C API for tuples to mutate them which led 354 to get right. It abused the C API for tuples to mutate them which led
355 to subtle reference counting and concurrency bugs. Furthermore, the 355 to subtle reference counting and concurrency bugs. Furthermore, the
356 introduction of protocol 4 and the prefetching optimization via peek() 356 introduction of protocol 4 and the prefetching optimization via peek()
357 significantly reduced the number of function calls we do. Thus, the 357 significantly reduced the number of function calls we do. Thus, the
358 benefits became marginal at best. */ 358 benefits became marginal at best. */
359 359
360 result = _PyObject_FastCall(func, &obj, 1, NULL); 360 result = _PyObject_CallArg1(func, obj);
361 Py_DECREF(obj); 361 Py_DECREF(obj);
362 return result; 362 return result;
363 } 363 }
364 364
365 /*************************************************************************/ 365 /*************************************************************************/
366 366
367 /* Internal data type used as the unpickling stack. */ 367 /* Internal data type used as the unpickling stack. */
368 typedef struct { 368 typedef struct {
369 PyObject_VAR_HEAD 369 PyObject_VAR_HEAD
370 PyObject **data; 370 PyObject **data;
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 { 1144 {
1145 PyObject *data; 1145 PyObject *data;
1146 Py_ssize_t read_size; 1146 Py_ssize_t read_size;
1147 1147
1148 assert(self->read != NULL); 1148 assert(self->read != NULL);
1149 1149
1150 if (_Unpickler_SkipConsumed(self) < 0) 1150 if (_Unpickler_SkipConsumed(self) < 0)
1151 return -1; 1151 return -1;
1152 1152
1153 if (n == READ_WHOLE_LINE) { 1153 if (n == READ_WHOLE_LINE) {
1154 data = _PyObject_FastCall(self->readline, NULL, 0, NULL); 1154 data = _PyObject_CallNoArg(self->readline);
1155 } 1155 }
1156 else { 1156 else {
1157 PyObject *len; 1157 PyObject *len;
1158 /* Prefetch some data without advancing the file pointer, if possible */ 1158 /* Prefetch some data without advancing the file pointer, if possible */
1159 if (self->peek && n < PREFETCH) { 1159 if (self->peek && n < PREFETCH) {
1160 len = PyLong_FromSsize_t(PREFETCH); 1160 len = PyLong_FromSsize_t(PREFETCH);
1161 if (len == NULL) 1161 if (len == NULL)
1162 return -1; 1162 return -1;
1163 data = _Pickle_FastCall(self->peek, len); 1163 data = _Pickle_FastCall(self->peek, len);
1164 if (data == NULL) { 1164 if (data == NULL) {
(...skipping 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 3941
3942 if (PyErr_ExceptionMatches(PyExc_AttributeError)) { 3942 if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
3943 PyErr_Clear(); 3943 PyErr_Clear();
3944 } 3944 }
3945 else { 3945 else {
3946 goto error; 3946 goto error;
3947 } 3947 }
3948 /* Check for a __reduce__ method. */ 3948 /* Check for a __reduce__ method. */
3949 reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__); 3949 reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__);
3950 if (reduce_func != NULL) { 3950 if (reduce_func != NULL) {
3951 reduce_value = _PyObject_FastCall(reduce_func, NULL, 0, NULL); 3951 reduce_value = _PyObject_CallNoArg(reduce_func);
3952 } 3952 }
3953 else { 3953 else {
3954 PyErr_Format(st->PicklingError, 3954 PyErr_Format(st->PicklingError,
3955 "can't pickle '%.200s' object: %R", 3955 "can't pickle '%.200s' object: %R",
3956 type->tp_name, obj); 3956 type->tp_name, obj);
3957 goto error; 3957 goto error;
3958 } 3958 }
3959 } 3959 }
3960 } 3960 }
3961 3961
(...skipping 3395 matching lines...) Expand 10 before | Expand all | Expand 10 after
7357 return NULL; 7357 return NULL;
7358 Py_INCREF(st->UnpicklingError); 7358 Py_INCREF(st->UnpicklingError);
7359 if (PyModule_AddObject(m, "UnpicklingError", st->UnpicklingError) < 0) 7359 if (PyModule_AddObject(m, "UnpicklingError", st->UnpicklingError) < 0)
7360 return NULL; 7360 return NULL;
7361 7361
7362 if (_Pickle_InitState(st) < 0) 7362 if (_Pickle_InitState(st) < 0)
7363 return NULL; 7363 return NULL;
7364 7364
7365 return m; 7365 return m;
7366 } 7366 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+