blob: 24fc881af15ccc8406c465373c0aaf652026c2e4 [file] [log] [blame]
Fred Drake64bc94e1999-06-17 15:11:35 +00001\section{\module{new} ---
2 Runtime implementation object creation}
3
4\declaremodule{builtin}{new}
5\sectionauthor{Moshe Zadka}{mzadka@geocities.com}
6\modulesynopsis{Interface to the creation of runtime implementation objects.}
7
8
9The \module{new} module allows an interface to the interpreter object
10creation functions. This is for use primarily in marshal-type functions,
11when a new object needs to be created ``magically'' and not by using the
12regular creation functions. This module provides a low-level interface
13to the interpreter, so care must be exercised when using this module.
14
15The \module{new} module defines the following functions:
16
17\begin{funcdesc}{instance}{class, dict}
Fred Drake26921da1999-06-17 18:58:02 +000018This function creates an instance of \var{class} with dictionary
Fred Drake64bc94e1999-06-17 15:11:35 +000019\var{dict} without calling the \method{__init__()} constructor. Note that
Fred Drake26921da1999-06-17 18:58:02 +000020there are no guarantees that the object will be in a consistent state.
Fred Drake64bc94e1999-06-17 15:11:35 +000021\end{funcdesc}
22
23\begin{funcdesc}{instancemethod}{function, instance, class}
24This function will return a method object, bound to \var{instance}, or
Fred Drakee0197891999-06-17 18:15:07 +000025unbound if \var{instance} is \code{None}. \var{function} must be
26callable, and \var{instance} must be an instance object or
27\code{None}.
Fred Drake64bc94e1999-06-17 15:11:35 +000028\end{funcdesc}
29
30\begin{funcdesc}{function}{code, globals\optional{, name\optional{argdefs}}}
31Returns a (Python) function with the given code and globals. If
Fred Drakee0197891999-06-17 18:15:07 +000032\var{name} is given, it must be a string or \code{None}. If it is a
33string, the function will have the given name, otherwise the function
34name will be taken from \code{\var{code}.co_name}. If
35\var{argdefs} is given, it must be a tuple and will be used to the
36determine the default values of parameters.
Fred Drake64bc94e1999-06-17 15:11:35 +000037\end{funcdesc}
38
39\begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,
40 constants, names, varnames, filename, name, firstlineno,
41 lnotab}
Fred Drakee0197891999-06-17 18:15:07 +000042This function is an interface to the \cfunction{PyCode_New()} C
Fred Drake64bc94e1999-06-17 15:11:35 +000043function.
Fred Drake9e0b6221999-06-29 15:45:09 +000044%XXX This is still undocumented!!!!!!!!!!!
Fred Drake64bc94e1999-06-17 15:11:35 +000045\end{funcdesc}
46
47\begin{funcdesc}{module}{name}
48This function returns a new module object with name \var{name}.
Fred Drakee0197891999-06-17 18:15:07 +000049\var{name} must be a string.
Fred Drake64bc94e1999-06-17 15:11:35 +000050\end{funcdesc}
51
52\begin{funcdesc}{classobj}{name, baseclasses, dict}
53This function returns a new class object, with name \var{name}, derived
54from \var{baseclasses} (which should be a tuple of classes) and with
Fred Drakee0197891999-06-17 18:15:07 +000055namespace \var{dict}.
Fred Drake64bc94e1999-06-17 15:11:35 +000056\end{funcdesc}