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
Xavier Thompson
cython
Commits
c0eca721
Commit
c0eca721
authored
Sep 02, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup cypclass builtin dict implementation
parent
85c51e76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
21 deletions
+15
-21
Cython/Includes/libcythonplus/dict.pxd
Cython/Includes/libcythonplus/dict.pxd
+15
-21
No files found.
Cython/Includes/libcythonplus/dict.pxd
View file @
c0eca721
...
...
@@ -175,17 +175,14 @@ cdef cypclass cypdict[K, V]:
V
__getitem__
(
self
,
const
key_type
key
)
except
~
const
:
it
=
self
.
_indices
.
find
(
key
)
end
=
self
.
_indices
.
end
()
if
it
!=
end
:
if
it
!=
self
.
_indices
.
end
():
return
self
.
_items
[
dereference
(
it
).
second
].
second
else
:
with
gil
:
raise
KeyError
(
"Getting nonexistent item"
)
with
gil
:
raise
KeyError
(
"Getting nonexistent item"
)
void
__setitem__
(
self
,
const
key_type
key
,
const
value_type
value
)
except
~
:
it
=
self
.
_indices
.
find
(
key
)
end
=
self
.
_indices
.
end
()
if
it
!=
end
:
if
it
!=
self
.
_indices
.
end
():
index
=
dereference
(
it
).
second
Cy_INCREF
(
value
)
Cy_DECREF
(
self
.
_items
[
index
].
second
)
...
...
@@ -201,22 +198,19 @@ cdef cypclass cypdict[K, V]:
void
__delitem__
(
self
,
const
key_type
key
)
except
~
:
it
=
self
.
_indices
.
find
(
key
)
end
=
self
.
_indices
.
end
()
if
it
!=
end
:
if
self
.
_active_iterators
==
0
:
index
=
dereference
(
it
).
second
Cy_DECREF
(
self
.
_items
[
index
].
first
)
Cy_DECREF
(
self
.
_items
[
index
].
second
)
self
.
_indices
.
erase
(
it
)
if
index
<
self
.
_items
.
size
()
-
1
:
self
.
_items
[
index
]
=
self
.
_items
[
self
.
_indices
.
size
()
-
1
]
self
.
_items
.
pop_back
()
else
:
with
gil
:
raise
RuntimeError
(
"Modifying a dictionary with active iterators"
)
else
:
if
it
==
self
.
_indices
.
end
():
with
gil
:
raise
KeyError
(
"Deleting nonexistent item"
)
if
self
.
_active_iterators
!=
0
:
with
gil
:
raise
RuntimeError
(
"Modifying a dictionary with active iterators"
)
index
=
dereference
(
it
).
second
Cy_DECREF
(
self
.
_items
[
index
].
first
)
Cy_DECREF
(
self
.
_items
[
index
].
second
)
self
.
_indices
.
erase
(
it
)
if
index
<
self
.
_items
.
size
()
-
1
:
self
.
_items
[
index
]
=
self
.
_items
[
self
.
_indices
.
size
()
-
1
]
self
.
_items
.
pop_back
()
void
update
(
self
,
const
cypdict
[
K
,
V
]
other
):
for
item
in
other
.
items
():
...
...
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