Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0de77d1d
Commit
0de77d1d
authored
May 05, 2004
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- note that __getinitargs__() is only for old-style classes
- describe __getnewargs__() (closes SF bug #873246)
parent
04d92c37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
Doc/lib/libpickle.tex
Doc/lib/libpickle.tex
+17
-2
No files found.
Doc/lib/libpickle.tex
View file @
0de77d1d
...
...
@@ -448,8 +448,8 @@ for more details.
When a pickled class instance is unpickled, its
\method
{__
init
__
()
}
method is normally
\emph
{
not
}
invoked. If it is desirable that the
\method
{__
init
__
()
}
method be called on unpickling, a
class can define
a method
\method
{__
getinitargs
__
()
}
, which should return a
\method
{__
init
__
()
}
method be called on unpickling, a
n old-style class
can define
a method
\method
{__
getinitargs
__
()
}
, which should return a
\emph
{
tuple
}
containing the arguments to be passed to the class
constructor (i.e.
\method
{__
init
__
()
}
). The
\method
{__
getinitargs
__
()
}
method is called at
...
...
@@ -458,6 +458,21 @@ the instance.
\withsubitem
{
(copy protocol)
}{
\ttindex
{__
getinitargs
__
()
}}
\withsubitem
{
(instance constructor)
}{
\ttindex
{__
init
__
()
}}
New-style types can provide a
\method
{__
getnewargs
__
()
}
method that is
used for protocol 2. Implementing this method is needed if the type
establishes some internal invariants when the instance is created, or
if the memory allocation is affected by the values passed to the
\method
{__
new
__
()
}
method for the type (as it is for tuples and
strings). Instances of a new-style type
\class
{
C
}
are created using
\begin{alltt}
obj = C.
__
new
__
(C, *
\var
{
args
}
)
\end{alltt}
where
\var
{
args
}
is the result of calling
\method
{__
getnewargs
__
()
}
on
the original object; if there is no
\method
{__
getnewargs
__
()
}
, an
empty tuple is assumed.
\withsubitem
{
(copy protocol)
}{
\ttindex
{__
getstate
__
()
}
\ttindex
{__
setstate
__
()
}}
\withsubitem
{
(instance attribute)
}{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment