blob: 9547b588a635e458b21d1076a47f6efa3952858a [file] [log] [blame]
Fred Drake64bc94e1999-06-17 15:11:35 +00001\section{\module{new} ---
Fred Drakef8ca7d82000-10-10 17:03:45 +00002 Creation of runtime internal objects}
Fred Drake64bc94e1999-06-17 15:11:35 +00003
4\declaremodule{builtin}{new}
Fred Drake57657bc2000-12-01 15:25:23 +00005\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
Fred Drake64bc94e1999-06-17 15:11:35 +00006\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
Fred Drakec37f5b32001-01-28 17:23:05 +000017\begin{funcdesc}{instance}{class\optional{, dict}}
Fred Drake26921da1999-06-17 18:58:02 +000018This function creates an instance of \var{class} with dictionary
Fred Drakec37f5b32001-01-28 17:23:05 +000019\var{dict} without calling the \method{__init__()} constructor. If
20\var{dict} is omitted or \code{None}, a new, empty dictionary is
21created for the new instance. Note that there are no guarantees that
22the object will be in a consistent state.
Fred Drake64bc94e1999-06-17 15:11:35 +000023\end{funcdesc}
24
25\begin{funcdesc}{instancemethod}{function, instance, class}
26This function will return a method object, bound to \var{instance}, or
Fred Drakee0197891999-06-17 18:15:07 +000027unbound if \var{instance} is \code{None}. \var{function} must be
28callable, and \var{instance} must be an instance object or
29\code{None}.
Fred Drake64bc94e1999-06-17 15:11:35 +000030\end{funcdesc}
31
Fred Drake2c4f5542000-10-10 22:00:03 +000032\begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}}
Fred Drake64bc94e1999-06-17 15:11:35 +000033Returns a (Python) function with the given code and globals. If
Fred Drakee0197891999-06-17 18:15:07 +000034\var{name} is given, it must be a string or \code{None}. If it is a
35string, the function will have the given name, otherwise the function
36name will be taken from \code{\var{code}.co_name}. If
Fred Drake2c4f5542000-10-10 22:00:03 +000037\var{argdefs} is given, it must be a tuple and will be used to
Fred Drakee0197891999-06-17 18:15:07 +000038determine the default values of parameters.
Fred Drake64bc94e1999-06-17 15:11:35 +000039\end{funcdesc}
40
41\begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,
42 constants, names, varnames, filename, name, firstlineno,
43 lnotab}
Fred Drakee0197891999-06-17 18:15:07 +000044This function is an interface to the \cfunction{PyCode_New()} C
Fred Drake64bc94e1999-06-17 15:11:35 +000045function.
Fred Drake9e0b6221999-06-29 15:45:09 +000046%XXX This is still undocumented!!!!!!!!!!!
Fred Drake64bc94e1999-06-17 15:11:35 +000047\end{funcdesc}
48
49\begin{funcdesc}{module}{name}
50This function returns a new module object with name \var{name}.
Fred Drakee0197891999-06-17 18:15:07 +000051\var{name} must be a string.
Fred Drake64bc94e1999-06-17 15:11:35 +000052\end{funcdesc}
53
54\begin{funcdesc}{classobj}{name, baseclasses, dict}
55This function returns a new class object, with name \var{name}, derived
56from \var{baseclasses} (which should be a tuple of classes) and with
Fred Drakee0197891999-06-17 18:15:07 +000057namespace \var{dict}.
Fred Drake64bc94e1999-06-17 15:11:35 +000058\end{funcdesc}