Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
3c19a9ca
Commit
3c19a9ca
authored
Feb 09, 2022
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: More fixes, add a note about @auto_pickle() and "__cinit__"
parent
48dbdf8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+2
-0
docs/src/userguide/special_methods.rst
docs/src/userguide/special_methods.rst
+8
-3
No files found.
docs/src/userguide/extension_types.rst
View file @
3c19a9ca
...
...
@@ -759,6 +759,8 @@ the above would be safe, and it may yield a significant speedup, depending on
your usage pattern.
.. _auto_pickle:
Controlling pickling
====================
...
...
docs/src/userguide/special_methods.rst
View file @
3c19a9ca
...
...
@@ -66,11 +66,11 @@ However, as in Python, it is the responsibility of the subclasses to call up the
hierarchy and make sure that the :meth:`__init__` methods in the base class are
called correctly. If a subclass forgets (or refuses) to call the :meth:`__init__`
method of one of its base classes, that method will not be called.
Also, if the object gets created by calling directly its :meth:`__new__` method
Also, if the object gets created by calling directly its :meth:`__new__` method
[#]_
(as opposed to calling the class itself), then none of the :meth:`__init__`
methods will be called.
The :meth:`__cinit__` method is where you should perform basic C-level
The :meth:`__cinit__` method is where you should perform basic
safety
C-level
initialisation of the object, possibly including allocation of any C data
structures that your object will own. In contrast to :meth:`__init__`,
your :meth:`__cinit__` method is guaranteed to be called exactly once.
...
...
@@ -86,7 +86,7 @@ where the normal rules for calling inherited methods apply.
Any arguments passed to the constructor will be passed to both the
:meth:`__cinit__` method and the :meth:`__init__` method. If you anticipate
subclassing your extension type, you may find it useful to give the
:meth:`__cinit__` method `
*` and `**
` arguments so that it can accept and
:meth:`__cinit__` method `
`*`` and ``**`
` arguments so that it can accept and
ignore arbitrary extra arguments, since the arguments that are passed through
the hierarchy during allocation cannot be changed by subclasses.
Alternatively, as a convenience, if you declare your :meth:`__cinit__` method
...
...
@@ -105,6 +105,11 @@ passed to the constructor without complaining about the signature mismatch.
See :ref:`existing-pointers-instantiation` for an example.
.. Note::
Implementing a :meth:`__cinit__` method currently excludes the type from
:ref:`auto-pickling <auto_pickle>`.
.. [#] https://docs.python.org/reference/datamodel.html#object.__new__
...
...
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