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
Boxiang Sun
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
Show 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
...
@@ -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
``__init__`` is available as well, it is not guaranteed to be run (for
instance, one could create a subclass and forget to call the
instance, one could create a subclass and forget to call the
ancestor'
s
constructor
).
Because
not
initializing
C
pointers
often
ancestor'
s
constructor
).
Because
not
initializing
C
pointers
often
leads
to
crashing
the
Python
interpreter
without
leaving
as
much
as
a
leads
to
hard
crashes
of
the
Python
interpreter
,
Cython
provides
stack
trace
,
Cython
provides
``
__cinit__
``
which
is
*
always
*
called
on
``
__cinit__
``
which
is
*
always
*
called
immediately
on
construction
,
construction
.
However
,
as
``
__cinit__
``
is
called
during
object
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
construction
,
``
self
``
is
not
fully
constructed
yet
,
and
one
must
avoid
doing
anything
with
``
self
``
but
assigning
to
``
cdef
``
fields
.
avoid
doing
anything
with
``
self
``
but
assigning
to
``
cdef
``
fields
.
Note
also
that
the
above
method
takes
no
parameters
,
although
subtypes
Note
also
that
the
above
method
takes
no
parameters
,
although
subtypes
may
want
to
accept
some
.
Although
it
is
guaranteed
to
get
called
,
the
may
want
to
accept
some
.
A
no
-
arguments
``
__cinit__
()``
method
is
a
no
-
arguments
``
__cinit__
()``
method
is
a
special
case
here
as
it
does
special
case
here
that
simply
does
not
receive
any
parameters
that
not
prevent
subclasses
from
adding
parameters
as
they
see
fit
.
If
were
passed
to
a
constructor
,
so
it
does
not
prevent
subclasses
from
parameters
are
added
they
must
match
those
of
any
declared
adding
parameters
.
If
parameters
are
used
in
the
signature
of
``
__init__
``
method
.
``
__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
Before
we
continue
implementing
the
other
methods
,
it
is
important
to
understand
that
the
above
implementation
is
not
safe
.
In
case
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