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
2d3d7be9
Commit
2d3d7be9
authored
Jan 19, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarification on __cinit__
parent
19a453c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
src/tutorial/clibraries.rst
src/tutorial/clibraries.rst
+12
-8
No files found.
src/tutorial/clibraries.rst
View file @
2d3d7be9
...
...
@@ -124,18 +124,22 @@ Note that it says ``__cinit__`` rather than ``__init__``. While
``__init__`` is available as well, it is not guaranteed to be run (for
instance, one could create a subclass and forget to call the
ancestor'
s
constructor
).
Because
not
initializing
C
pointers
often
leads
to
crashing
the
Python
interpreter
without
leaving
as
much
as
a
stack
trace
,
Cython
provides
``
__cinit__
``
which
is
*
always
*
called
on
construction
.
However
,
as
``
__cinit__
``
is
called
during
object
leads
to
hard
crashes
of
the
Python
interpreter
,
Cython
provides
``
__cinit__
``
which
is
*
always
*
called
immediately
on
construction
,
before
CPython
even
considers
calling
``
__init__
``,
and
which
therefore
is
the
right
place
to
initialise
``
cdef
``
fields
of
the
new
instance
.
However
,
as
``
__cinit__
``
is
called
during
object
construction
,
``
self
``
is
not
fully
constructed
yet
,
and
one
must
avoid
doing
anything
with
``
self
``
but
assigning
to
``
cdef
``
fields
.
Note
also
that
the
above
method
takes
no
parameters
,
although
subtypes
may
want
to
accept
some
.
Although
it
is
guaranteed
to
get
called
,
the
no
-
arguments
``
__cinit__
()``
method
is
a
special
case
here
as
it
does
not
prevent
subclasses
from
adding
parameters
as
they
see
fit
.
If
parameters
are
added
they
must
match
those
of
any
declared
``
__init__
``
method
.
may
want
to
accept
some
.
A
no
-
arguments
``
__cinit__
()``
method
is
a
special
case
here
that
simply
does
not
receive
any
parameters
that
were
passed
to
a
constructor
,
so
it
does
not
prevent
subclasses
from
adding
parameters
.
If
parameters
are
used
in
the
signature
of
``
__cinit__
()``,
they
must
match
those
of
any
declared
``
__init__
``
method
of
classes
in
the
class
hierarchy
that
are
used
to
instantiate
the
type
.
Before
we
continue
implementing
the
other
methods
,
it
is
important
to
understand
that
the
above
implementation
is
not
safe
.
In
case
...
...
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