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.
15 The
\module{new
} module defines the following functions:
17 \begin{funcdesc
}{instance
}{class
\optional{, dict
}}
18 This function creates an instance of
\var{class
} with dictionary
19 \var{dict
} without calling the
\method{__init__()
} constructor. If
20 \var{dict
} is omitted or
\code{None
}, a new, empty dictionary is
21 created for the new instance. Note that there are no guarantees that
22 the object will be in a consistent state.
25 \begin{funcdesc
}{instancemethod
}{function, instance, class
}
26 This function will return a method object, bound to
\var{instance
}, or
27 unbound if
\var{instance
} is
\code{None
}.
\var{function
} must be
28 callable, and
\var{instance
} must be an instance object or
32 \begin{funcdesc
}{function
}{code, globals
\optional{, name
\optional{, argdefs
}}}
33 Returns a (Python) function with the given code and globals. If
34 \var{name
} is given, it must be a string or
\code{None
}. If it is a
35 string, the function will have the given name, otherwise the function
36 name will be taken from
\code{\var{code
}.co_name
}. If
37 \var{argdefs
} is given, it must be a tuple and will be used to
38 determine the default values of parameters.
41 \begin{funcdesc
}{code
}{argcount, nlocals, stacksize, flags, codestring,
42 constants, names, varnames, filename, name, firstlineno,
44 This function is an interface to the
\cfunction{PyCode_New()
} C
46 %XXX This is still undocumented!!!!!!!!!!!
49 \begin{funcdesc
}{module
}{name
}
50 This function returns a new module object with name
\var{name
}.
51 \var{name
} must be a string.
54 \begin{funcdesc
}{classobj
}{name, baseclasses, dict
}
55 This function returns a new class object, with name
\var{name
}, derived
56 from
\var{baseclasses
} (which should be a tuple of classes) and with