keyword arguments and faster function calls

This commit is contained in:
Guido van Rossum 1995-07-18 14:21:06 +00:00
parent e15dee5e3c
commit 884afd654a
9 changed files with 38 additions and 32 deletions

View file

@ -31,6 +31,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Interface to random parts in ceval.c */
PyObject *PyEval_CallObject Py_PROTO((PyObject *, PyObject *));
PyObject *PyEval_CallObjectWithKeywords
Py_PROTO((PyObject *, PyObject *, PyObject *));
PyObject *PyEval_GetBuiltins Py_PROTO((void));
PyObject *PyEval_GetGlobals Py_PROTO((void));

View file

@ -28,25 +28,29 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Definitions for compiled intermediate code */
/* An intermediate code fragment contains:
- a string that encodes the instructions,
- a list of the constants,
- a list of the names used,
- the filename from which it was compiled,
- the name of the object for which it was compiled. */
/* Definitions for bytecode */
/* Bytecode object */
typedef struct {
PyObject_HEAD
PyStringObject *co_code; /* instruction opcodes */
PyObject *co_consts; /* list of immutable constant objects */
PyObject *co_names; /* list of stringobjects */
PyObject *co_filename; /* string */
PyObject *co_name; /* string */
int co_argcount; /* #arguments, except *args */
int co_nlocals; /* #local variables */
int co_flags; /* CO_..., see below */
PyStringObject *co_code; /* instruction opcodes */
PyObject *co_consts; /* list (constants used) */
PyObject *co_names; /* list of strings (names used) */
PyObject *co_varnames; /* tuple of strings (local variable names) */
/* The rest doesn't count for hash/cmp */
PyObject *co_filename; /* string (where it was loaded from) */
PyObject *co_name; /* string (name, for reference) */
} PyCodeObject;
/* Masks for co_flags above */
#define CO_OPTIMIZED 0x0001
#define CO_NEWLOCALS 0x0002
#define CO_VARARGS 0x0004
#define CO_VARKEYWORDS 0x0008
extern DL_IMPORT(PyTypeObject) PyCode_Type;
#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
@ -55,8 +59,9 @@ extern DL_IMPORT(PyTypeObject) PyCode_Type;
/* Public interface */
struct _node; /* Declare the existence of this type */
PyCodeObject *PyNode_Compile Py_PROTO((struct _node *, char *));
PyCodeObject *PyCode_New
Py_PROTO((PyObject *, PyObject *, PyObject *, PyObject *, PyObject *));
PyCodeObject *PyCode_New Py_PROTO((
int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
PyObject *, PyObject *)); /* same as struct above */
#ifdef __cplusplus
}

View file

@ -30,8 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Interface to execute compiled code */
PyObject *PyEval_EvalCode
Py_PROTO((PyCodeObject *, PyObject *, PyObject *, PyObject *, PyObject *));
PyObject *PyEval_EvalCode Py_PROTO((PyCodeObject *, PyObject *, PyObject *));
#ifdef __cplusplus
}

View file

@ -45,7 +45,6 @@ typedef struct _frame {
PyObject *f_locals; /* local symbol table (PyDictObject) */
PyObject *f_owner; /* owner (e.g. class or module) or NULL */
PyObject *f_fastlocals; /* fast local variables (PyListObject) */
PyObject *f_localmap; /* local variable names (PyDictObject) */
PyObject **f_valuestack; /* malloc'ed array */
PyTryBlock *f_blockstack; /* malloc'ed array */
int f_nvalues; /* size of f_valuestack */

View file

@ -34,10 +34,9 @@ typedef struct {
PyObject_HEAD
PyObject *func_code;
PyObject *func_globals;
PyObject *func_name;
int func_argcount;
PyObject *func_argdefs;
PyObject *func_defaults;
PyObject *func_doc;
PyObject *func_name;
} PyFunctionObject;
extern DL_IMPORT(PyTypeObject) PyFunction_Type;
@ -47,8 +46,8 @@ extern DL_IMPORT(PyTypeObject) PyFunction_Type;
extern PyObject *PyFunction_New Py_PROTO((PyObject *, PyObject *));
extern PyObject *PyFunction_GetCode Py_PROTO((PyObject *));
extern PyObject *PyFunction_GetGlobals Py_PROTO((PyObject *));
extern PyObject *PyFunction_GetArgStuff Py_PROTO((PyObject *, int *));
extern int PyFunction_SetArgStuff Py_PROTO((PyObject *, int, PyObject *));
extern PyObject *PyFunction_GetDefaults Py_PROTO((PyObject *));
extern int PyFunction_SetDefaults Py_PROTO((PyObject *, PyObject *));
#ifdef __cplusplus
}

View file

@ -217,7 +217,7 @@ typedef struct _typeobject {
/* More standard operations (at end for binary compatibility) */
hashfunc tp_hash;
binaryfunc tp_call;
ternaryfunc tp_call;
reprfunc tp_str;
/* Space for future expansion */

View file

@ -40,7 +40,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define UNARY_NEGATIVE 11
#define UNARY_NOT 12
#define UNARY_CONVERT 13
#define UNARY_CALL 14
#define UNARY_INVERT 15
#define BINARY_MULTIPLY 20
@ -49,7 +49,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define BINARY_ADD 23
#define BINARY_SUBTRACT 24
#define BINARY_SUBSCR 25
#define BINARY_CALL 26
#define SLICE 30
/* Also uses 31-33 */
@ -75,13 +74,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define PRINT_NEWLINE 72
#define BREAK_LOOP 80
#define RAISE_EXCEPTION 81
#define LOAD_LOCALS 82
#define RETURN_VALUE 83
#define LOAD_GLOBALS 84
#define EXEC_STMT 85
#define BUILD_FUNCTION 86
#define POP_BLOCK 87
#define END_FINALLY 88
#define BUILD_CLASS 89
@ -125,7 +123,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define SETUP_EXCEPT 121 /* "" */
#define SETUP_FINALLY 122 /* "" */
#define RESERVE_FAST 123 /* Number of local variables */
#define LOAD_FAST 124 /* Local variable number */
#define STORE_FAST 125 /* Local variable number */
#define DELETE_FAST 126 /* Local variable number */
@ -139,6 +136,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
#define MAKE_FUNCTION 132 /* #defaults */
/* Comparison operator codes (argument to COMPARE_OP) */
enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};

View file

@ -1 +1 @@
#define PATCHLEVEL "1.2"
#define PATCHLEVEL "1.3b1"

View file

@ -37,6 +37,10 @@ PyObject *PyTraceBack_Fetch Py_PROTO((void));
int PyTraceBack_Store Py_PROTO((PyObject *));
int PyTraceBack_Print Py_PROTO((PyObject *, PyObject *));
/* Reveale traceback type so we can typecheck traceback objects */
extern PyTypeObject PyTraceback_Type;
#define PyTraceback_Check(v) ((v)->ob_type == &PyTraceback_Type)
#ifdef __cplusplus
}
#endif