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{, argdefs
}}}
34 Returns a (Python) function with the given code and globals. If
35 \var{name
} is given, it must be a string or
\code{None
}. If it is a
36 string, the function will have the given name, otherwise the function
37 name will be taken from
\code{\var{code
}.co_name
}. If
38 \var{argdefs
} is given, it must be a tuple and will be used to
39 determine the default values of parameters.
42 \begin{funcdesc
}{code
}{argcount, nlocals, stacksize, flags, codestring,
43 constants, names, varnames, filename, name, firstlineno,
45 This function is an interface to the
\cfunction{PyCode_New()
} C
47 %XXX This is still undocumented!!!!!!!!!!!
50 \begin{funcdesc
}{module
}{name
[, doc
]}
51 This function returns a new module object with name
\var{name
}.
52 \var{name
} must be a string.
53 The optional
\var{doc
} argument can have any type.
56 \begin{funcdesc
}{classobj
}{name, baseclasses, dict
}
57 This function returns a new class object, with name
\var{name
}, derived
58 from
\var{baseclasses
} (which should be a tuple of classes) and with