1 \section{\module{new
} ---
2 Creation of runtime internal objects
}
4 \declaremodule{builtin
}{new
}
5 \sectionauthor{Moshe Zadka
}{moshez@zadka.site.co.il
}
6 \modulesynopsis{Interface to the creation of runtime implementation objects.
}
9 The
\module{new
} module allows an interface to the interpreter object
10 creation functions. This is for use primarily in marshal-type functions,
11 when a new object needs to be created ``magically'' and not by using the
12 regular creation functions. This module provides a low-level interface
13 to the interpreter, so care must be exercised when using this module.
14 It is possible to supply non-sensical arguments which crash the
15 interpreter when the object is used.
17 The
\module{new
} module defines the following functions:
19 \begin{funcdesc
}{instance
}{class
\optional{, dict
}}
20 This function creates an instance of
\var{class
} with dictionary
21 \var{dict
} without calling the
\method{__init__()
} constructor. If
22 \var{dict
} is omitted or
\code{None
}, a new, empty dictionary is
23 created for the new instance. Note that there are no guarantees that
24 the object will be in a consistent state.
27 \begin{funcdesc
}{instancemethod
}{function, instance, class
}
28 This function will return a method object, bound to
\var{instance
}, or
29 unbound if
\var{instance
} is
\code{None
}.
\var{function
} must be
33 \begin{funcdesc
}{function
}{code, globals
\optional{, name
\optional{,
34 argdefs
\optional{, closure
}}}}
35 Returns a (Python) function with the given code and globals. If
36 \var{name
} is given, it must be a string or
\code{None
}. If it is a
37 string, the function will have the given name, otherwise the function
38 name will be taken from
\code{\var{code
}.co_name
}. If
39 \var{argdefs
} is given, it must be a tuple and will be used to
40 determine the default values of parameters. If
\var{closure
} is given,
41 it must be
\code{None
} or a tuple of cell objects containing objects
42 to bind to the names in
\code{\var{code
}.co_freevars
}.
45 \begin{funcdesc
}{code
}{argcount, nlocals, stacksize, flags, codestring,
46 constants, names, varnames, filename, name, firstlineno,
48 This function is an interface to the
\cfunction{PyCode_New()
} C
50 %XXX This is still undocumented!!!!!!!!!!!
53 \begin{funcdesc
}{module
}{name
[, doc
]}
54 This function returns a new module object with name
\var{name
}.
55 \var{name
} must be a string.
56 The optional
\var{doc
} argument can have any type.
59 \begin{funcdesc
}{classobj
}{name, baseclasses, dict
}
60 This function returns a new class object, with name
\var{name
}, derived
61 from
\var{baseclasses
} (which should be a tuple of classes) and with