Skip to content

Commit 4be534b

Browse files
authored
Dict->IdDict in exception types (#927)
* Dict->IdDict in exception types Dicts use extensive specialization and this adds latency. IdDicts don't and are the go-to associative container for type-keys. * Rely on `const` to solve inference problems The `::Dict`, being an abstract annotation, wouldn't have been all that much help anyway.
1 parent c7b069a commit 4be534b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/exception.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ end
140140
#########################################################################
141141
# Mapping of Julia Exception types to Python exceptions
142142

143-
const pyexc = Dict{DataType, PyPtr}()
143+
const pyexc = IdDict{DataType, PyPtr}()
144144
mutable struct PyIOError <: Exception end
145145

146146
function pyexc_initialize()
@@ -213,7 +213,7 @@ end
213213

214214
function pyraise(e, bt = nothing)
215215
eT = typeof(e)
216-
pyeT = haskey(pyexc::Dict, eT) ? pyexc[eT] : pyexc[Exception]
216+
pyeT = haskey(pyexc, eT) ? pyexc[eT] : pyexc[Exception]
217217
err = PyJlError(e, bt)
218218
ccall((@pysym :PyErr_SetObject), Cvoid, (PyPtr, PyPtr),
219219
pyeT, PyObject(err))

src/io.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
function ioraise(e, bt = nothing)
1212
if isa(e, MethodError) || isa(e, ErrorException)
1313
ccall((@pysym :PyErr_SetString), Cvoid, (PyPtr, Cstring),
14-
(pyexc::Dict)[PyIOError],
14+
pyexc[PyIOError],
1515
showerror_string(e, bt))
1616
else
1717
pyraise(e, bt)

0 commit comments

Comments
 (0)