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

Side by Side Diff: Objects/weakrefobject.c

Issue 29259: Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects
Patch Set: Created 3 years, 2 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:
View unified diff | Download patch
OLDNEW
1 #include "Python.h" 1 #include "Python.h"
2 #include "structmember.h" 2 #include "structmember.h"
3 3
4 4
5 #define GET_WEAKREFS_LISTPTR(o) \ 5 #define GET_WEAKREFS_LISTPTR(o) \
6 ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o)) 6 ((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o))
7 7
8 8
9 Py_ssize_t 9 Py_ssize_t
10 _PyWeakref_GetWeakrefCount(PyWeakReference *head) 10 _PyWeakref_GetWeakrefCount(PyWeakReference *head)
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 _Py_IDENTIFIER(special); \ 454 _Py_IDENTIFIER(special); \
455 UNWRAP(proxy); \ 455 UNWRAP(proxy); \
456 return _PyObject_CallMethodId(proxy, &PyId_##special, NULL); \ 456 return _PyObject_CallMethodId(proxy, &PyId_##special, NULL); \
457 } 457 }
458 458
459 459
460 /* direct slots */ 460 /* direct slots */
461 461
462 WRAP_BINARY(proxy_getattr, PyObject_GetAttr) 462 WRAP_BINARY(proxy_getattr, PyObject_GetAttr)
463 WRAP_UNARY(proxy_str, PyObject_Str) 463 WRAP_UNARY(proxy_str, PyObject_Str)
464 WRAP_TERNARY(proxy_call, PyEval_CallObjectWithKeywords) 464
465 static PyObject *
466 proxy_call(PyObject *proxy, PyObject **args, Py_ssize_t nargs,
467 PyObject *kwnames)
468 {
469 UNWRAP(proxy);
470 return _PyObject_FastCallKeywords(proxy, args, nargs, kwnames);
471 }
472
465 473
466 static PyObject * 474 static PyObject *
467 proxy_repr(PyWeakReference *proxy) 475 proxy_repr(PyWeakReference *proxy)
468 { 476 {
469 return PyUnicode_FromFormat( 477 return PyUnicode_FromFormat(
470 "<weakproxy at %p to %s at %p>", 478 "<weakproxy at %p to %s at %p>",
471 proxy, 479 proxy,
472 Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name, 480 Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name,
473 PyWeakref_GET_OBJECT(proxy)); 481 PyWeakref_GET_OBJECT(proxy));
474 } 482 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 (destructor)proxy_dealloc, /* tp_dealloc */ 712 (destructor)proxy_dealloc, /* tp_dealloc */
705 0, /* tp_print */ 713 0, /* tp_print */
706 0, /* tp_getattr */ 714 0, /* tp_getattr */
707 0, /* tp_setattr */ 715 0, /* tp_setattr */
708 0, /* tp_reserved */ 716 0, /* tp_reserved */
709 (unaryfunc)proxy_repr, /* tp_repr */ 717 (unaryfunc)proxy_repr, /* tp_repr */
710 &proxy_as_number, /* tp_as_number */ 718 &proxy_as_number, /* tp_as_number */
711 &proxy_as_sequence, /* tp_as_sequence */ 719 &proxy_as_sequence, /* tp_as_sequence */
712 &proxy_as_mapping, /* tp_as_mapping */ 720 &proxy_as_mapping, /* tp_as_mapping */
713 0, /* tp_hash */ 721 0, /* tp_hash */
714 proxy_call, /* tp_call */ 722 0, /* tp_call */
715 proxy_str, /* tp_str */ 723 proxy_str, /* tp_str */
716 proxy_getattr, /* tp_getattro */ 724 proxy_getattr, /* tp_getattro */
717 (setattrofunc)proxy_setattr, /* tp_setattro */ 725 (setattrofunc)proxy_setattr, /* tp_setattro */
718 0, /* tp_as_buffer */ 726 0, /* tp_as_buffer */
719 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 727 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
720 0, /* tp_doc */ 728 0, /* tp_doc */
721 (traverseproc)gc_traverse, /* tp_traverse */ 729 (traverseproc)gc_traverse, /* tp_traverse */
722 (inquiry)gc_clear, /* tp_clear */ 730 (inquiry)gc_clear, /* tp_clear */
723 proxy_richcompare, /* tp_richcompare */ 731 proxy_richcompare, /* tp_richcompare */
724 0, /* tp_weaklistoffset */ 732 0, /* tp_weaklistoffset */
725 (getiterfunc)proxy_iter, /* tp_iter */ 733 (getiterfunc)proxy_iter, /* tp_iter */
726 (iternextfunc)proxy_iternext, /* tp_iternext */ 734 (iternextfunc)proxy_iternext, /* tp_iternext */
735
736 .tp_fastcall = (fastternaryfunc)proxy_call,
727 }; 737 };
728 738
729 739
730 740
731 PyObject * 741 PyObject *
732 PyWeakref_NewRef(PyObject *ob, PyObject *callback) 742 PyWeakref_NewRef(PyObject *ob, PyObject *callback)
733 { 743 {
734 PyWeakReference *result = NULL; 744 PyWeakReference *result = NULL;
735 PyWeakReference **list; 745 PyWeakReference **list;
736 PyWeakReference *ref, *proxy; 746 PyWeakReference *ref, *proxy;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 PyObject *item = PyTuple_GET_ITEM(tuple, i * 2); 960 PyObject *item = PyTuple_GET_ITEM(tuple, i * 2);
951 handle_callback((PyWeakReference *)item, callback); 961 handle_callback((PyWeakReference *)item, callback);
952 } 962 }
953 } 963 }
954 Py_DECREF(tuple); 964 Py_DECREF(tuple);
955 } 965 }
956 assert(!PyErr_Occurred()); 966 assert(!PyErr_Occurred());
957 PyErr_Restore(err_type, err_value, err_tb); 967 PyErr_Restore(err_type, err_value, err_tb);
958 } 968 }
959 } 969 }
OLDNEW
« Objects/typeobject.c ('K') | « Objects/typeobject.c ('k') | Tools/gdb/libpython.py » ('j') | no next file with comments »

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