blob: bf214cb574d0517eee5de0ce971bd0c5e71755c3 [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}
18This function creates an instance of \class{class} with dictionary
19\var{dict} without calling the \method{__init__()} constructor. Note that
20this means that there are no guarantees that the object will be in a
21consistent state.
Fred Drake64bc94e1999-06-17 15:11:35 +000022\end{funcdesc}
23
24\begin{funcdesc}{instancemethod}{function, instance, class}
25This function will return a method object, bound to \var{instance}, or
Fred Drakee0197891999-06-17 18:15:07 +000026unbound if \var{instance} is \code{None}. \var{function} must be
27callable, and \var{instance} must be an instance object or
28\code{None}.
Fred Drake64bc94e1999-06-17 15:11:35 +000029\end{funcdesc}
30
31\begin{funcdesc}{function}{code, globals\optional{, name\optional{argdefs}}}
32Returns a (Python) function with the given code and globals. If
Fred Drakee0197891999-06-17 18:15:07 +000033\var{name} is given, it must be a string or \code{None}. If it is a
34string, the function will have the given name, otherwise the function
35name will be taken from \code{\var{code}.co_name}. If
36\var{argdefs} is given, it must be a tuple and will be used to the
37determine the default values of parameters.
Fred Drake64bc94e1999-06-17 15:11:35 +000038\end{funcdesc}
39
40\begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,
41 constants, names, varnames, filename, name, firstlineno,
42 lnotab}
Fred Drakee0197891999-06-17 18:15:07 +000043This function is an interface to the \cfunction{PyCode_New()} C
Fred Drake64bc94e1999-06-17 15:11:35 +000044function.
45XXX This is still undocumented!!!!!!!!!!!
46\end{funcdesc}
47
48\begin{funcdesc}{module}{name}
49This function returns a new module object with name \var{name}.
Fred Drakee0197891999-06-17 18:15:07 +000050\var{name} must be a string.
Fred Drake64bc94e1999-06-17 15:11:35 +000051\end{funcdesc}
52
53\begin{funcdesc}{classobj}{name, baseclasses, dict}
54This function returns a new class object, with name \var{name}, derived
55from \var{baseclasses} (which should be a tuple of classes) and with
Fred Drakee0197891999-06-17 18:15:07 +000056namespace \var{dict}.
Fred Drake64bc94e1999-06-17 15:11:35 +000057\end{funcdesc}