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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
776ca207
Commit
776ca207
authored
Jul 01, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
__new__ clarification
parent
cad7d1de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
docs/sharing_declarations.rst
docs/sharing_declarations.rst
+1
-1
docs/special_methods.rst
docs/special_methods.rst
+10
-2
No files found.
docs/sharing_declarations.rst
View file @
776ca207
...
...
@@ -212,7 +212,7 @@ and another module which uses it.::
# Shrubbing.pyx
cdef class Shrubbery:
def __
new
__(self, int w, int l):
def __
cinit
__(self, int w, int l):
self.width = w
self.length = l
...
...
docs/special_methods.rst
View file @
776ca207
...
...
@@ -65,12 +65,20 @@ subclassing your extension type in Python, you may find it useful to give the
:meth:`__cinit__` method `*` and `**` arguments so that it can accept and
ignore extra arguments. Otherwise, any Python subclass which has an
:meth:`__init__` with a different signature will have to override
:meth:`__new__` as well as :meth:`__init__`, which the writer of a Python
class wouldn't expect to have to do. As a convenience, if you declare
:meth:`__new__`
[#]
as well as :meth:`__init__`, which the writer of a Python
class wouldn't expect to have to do. A
lternatively, a
s a convenience, if you declare
your :meth:`__cinit__`` method to take no arguments (other than self) it
will simply ignore any extra arguments passed to the constructor without
complaining about the signature mismatch.
.. Note: Older Cython files may use :meth:`__new__` rather than :meth:`__cinit__`. The two are synonyms.
The name change from :meth:`__new__` to :meth:`__cinit__` was to avoid
confusion with Python :meth:`__new__` (which is an entirely different
concept) and eventually the use of :meth:`__new__` in Cython will be
disallowed to pave the way for supporting Python-style :meth:`__new__`
.. [#] http://docs.python.org/reference/datamodel.html#object.__new__
Finalization method: :meth:`__dealloc__`
----------------------------------------
...
...
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