Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 884afd6

Browse files
committed
keyword arguments and faster function calls
1 parent e15dee5 commit 884afd6

9 files changed

Lines changed: 38 additions & 32 deletions

File tree

Include/ceval.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131
/* Interface to random parts in ceval.c */
3232

3333
PyObject *PyEval_CallObject Py_PROTO((PyObject *, PyObject *));
34+
PyObject *PyEval_CallObjectWithKeywords
35+
Py_PROTO((PyObject *, PyObject *, PyObject *));
3436

3537
PyObject *PyEval_GetBuiltins Py_PROTO((void));
3638
PyObject *PyEval_GetGlobals Py_PROTO((void));

Include/compile.h

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,29 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2828
2929
******************************************************************/
3030

31-
/* Definitions for compiled intermediate code */
32-
33-
34-
/* An intermediate code fragment contains:
35-
- a string that encodes the instructions,
36-
- a list of the constants,
37-
- a list of the names used,
38-
- the filename from which it was compiled,
39-
- the name of the object for which it was compiled. */
31+
/* Definitions for bytecode */
4032

33+
/* Bytecode object */
4134
typedef struct {
4235
PyObject_HEAD
43-
PyStringObject *co_code; /* instruction opcodes */
44-
PyObject *co_consts; /* list of immutable constant objects */
45-
PyObject *co_names; /* list of stringobjects */
46-
PyObject *co_filename; /* string */
47-
PyObject *co_name; /* string */
36+
int co_argcount; /* #arguments, except *args */
37+
int co_nlocals; /* #local variables */
38+
int co_flags; /* CO_..., see below */
39+
PyStringObject *co_code; /* instruction opcodes */
40+
PyObject *co_consts; /* list (constants used) */
41+
PyObject *co_names; /* list of strings (names used) */
42+
PyObject *co_varnames; /* tuple of strings (local variable names) */
43+
/* The rest doesn't count for hash/cmp */
44+
PyObject *co_filename; /* string (where it was loaded from) */
45+
PyObject *co_name; /* string (name, for reference) */
4846
} PyCodeObject;
4947

48+
/* Masks for co_flags above */
49+
#define CO_OPTIMIZED 0x0001
50+
#define CO_NEWLOCALS 0x0002
51+
#define CO_VARARGS 0x0004
52+
#define CO_VARKEYWORDS 0x0008
53+
5054
extern DL_IMPORT(PyTypeObject) PyCode_Type;
5155

5256
#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
@@ -55,8 +59,9 @@ extern DL_IMPORT(PyTypeObject) PyCode_Type;
5559
/* Public interface */
5660
struct _node; /* Declare the existence of this type */
5761
PyCodeObject *PyNode_Compile Py_PROTO((struct _node *, char *));
58-
PyCodeObject *PyCode_New
59-
Py_PROTO((PyObject *, PyObject *, PyObject *, PyObject *, PyObject *));
62+
PyCodeObject *PyCode_New Py_PROTO((
63+
int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
64+
PyObject *, PyObject *)); /* same as struct above */
6065

6166
#ifdef __cplusplus
6267
}

Include/eval.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3030

3131
/* Interface to execute compiled code */
3232

33-
PyObject *PyEval_EvalCode
34-
Py_PROTO((PyCodeObject *, PyObject *, PyObject *, PyObject *, PyObject *));
33+
PyObject *PyEval_EvalCode Py_PROTO((PyCodeObject *, PyObject *, PyObject *));
3534

3635
#ifdef __cplusplus
3736
}

Include/frameobject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ typedef struct _frame {
4545
PyObject *f_locals; /* local symbol table (PyDictObject) */
4646
PyObject *f_owner; /* owner (e.g. class or module) or NULL */
4747
PyObject *f_fastlocals; /* fast local variables (PyListObject) */
48-
PyObject *f_localmap; /* local variable names (PyDictObject) */
4948
PyObject **f_valuestack; /* malloc'ed array */
5049
PyTryBlock *f_blockstack; /* malloc'ed array */
5150
int f_nvalues; /* size of f_valuestack */

Include/funcobject.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ typedef struct {
3434
PyObject_HEAD
3535
PyObject *func_code;
3636
PyObject *func_globals;
37-
PyObject *func_name;
38-
int func_argcount;
39-
PyObject *func_argdefs;
37+
PyObject *func_defaults;
4038
PyObject *func_doc;
39+
PyObject *func_name;
4140
} PyFunctionObject;
4241

4342
extern DL_IMPORT(PyTypeObject) PyFunction_Type;
@@ -47,8 +46,8 @@ extern DL_IMPORT(PyTypeObject) PyFunction_Type;
4746
extern PyObject *PyFunction_New Py_PROTO((PyObject *, PyObject *));
4847
extern PyObject *PyFunction_GetCode Py_PROTO((PyObject *));
4948
extern PyObject *PyFunction_GetGlobals Py_PROTO((PyObject *));
50-
extern PyObject *PyFunction_GetArgStuff Py_PROTO((PyObject *, int *));
51-
extern int PyFunction_SetArgStuff Py_PROTO((PyObject *, int, PyObject *));
49+
extern PyObject *PyFunction_GetDefaults Py_PROTO((PyObject *));
50+
extern int PyFunction_SetDefaults Py_PROTO((PyObject *, PyObject *));
5251

5352
#ifdef __cplusplus
5453
}

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ typedef struct _typeobject {
217217
/* More standard operations (at end for binary compatibility) */
218218

219219
hashfunc tp_hash;
220-
binaryfunc tp_call;
220+
ternaryfunc tp_call;
221221
reprfunc tp_str;
222222

223223
/* Space for future expansion */

Include/opcode.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4040
#define UNARY_NEGATIVE 11
4141
#define UNARY_NOT 12
4242
#define UNARY_CONVERT 13
43-
#define UNARY_CALL 14
43+
4444
#define UNARY_INVERT 15
4545

4646
#define BINARY_MULTIPLY 20
@@ -49,7 +49,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4949
#define BINARY_ADD 23
5050
#define BINARY_SUBTRACT 24
5151
#define BINARY_SUBSCR 25
52-
#define BINARY_CALL 26
5352

5453
#define SLICE 30
5554
/* Also uses 31-33 */
@@ -75,13 +74,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
7574
#define PRINT_NEWLINE 72
7675

7776
#define BREAK_LOOP 80
78-
#define RAISE_EXCEPTION 81
77+
7978
#define LOAD_LOCALS 82
8079
#define RETURN_VALUE 83
81-
#define LOAD_GLOBALS 84
80+
8281
#define EXEC_STMT 85
8382

84-
#define BUILD_FUNCTION 86
8583
#define POP_BLOCK 87
8684
#define END_FINALLY 88
8785
#define BUILD_CLASS 89
@@ -125,7 +123,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
125123
#define SETUP_EXCEPT 121 /* "" */
126124
#define SETUP_FINALLY 122 /* "" */
127125

128-
#define RESERVE_FAST 123 /* Number of local variables */
129126
#define LOAD_FAST 124 /* Local variable number */
130127
#define STORE_FAST 125 /* Local variable number */
131128
#define DELETE_FAST 126 /* Local variable number */
@@ -139,6 +136,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
139136

140137
#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
141138
#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
139+
#define MAKE_FUNCTION 132 /* #defaults */
142140

143141
/* Comparison operator codes (argument to COMPARE_OP) */
144142
enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};

Include/patchlevel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define PATCHLEVEL "1.2"
1+
#define PATCHLEVEL "1.3b1"

Include/traceback.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ PyObject *PyTraceBack_Fetch Py_PROTO((void));
3737
int PyTraceBack_Store Py_PROTO((PyObject *));
3838
int PyTraceBack_Print Py_PROTO((PyObject *, PyObject *));
3939

40+
/* Reveale traceback type so we can typecheck traceback objects */
41+
extern PyTypeObject PyTraceback_Type;
42+
#define PyTraceback_Check(v) ((v)->ob_type == &PyTraceback_Type)
43+
4044
#ifdef __cplusplus
4145
}
4246
#endif

0 commit comments

Comments
 (0)