Skip to content

Commit 4f24812

Browse files
author
Christopher Doris
committed
save 2 seconds startup time by removing an invalidating method
1 parent 386a4ff commit 4f24812

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/PyObject.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ pylazyobject(mk) = PyObject(Val(:lazy), mk)
6666

6767
C.PyObject_TryConvert__initial(o, ::Type{PyObject}) = C.putresult(pyborrowedobject(o))
6868

69-
Base.convert(::Type{PyObject}, x::PyObject) = x
70-
Base.convert(::Type{Any}, x::PyObject) = x
71-
Base.convert(::Type{T}, x::PyObject) where {T} = x isa T ? x : pyconvert(T, x)
72-
Base.convert(::Type{PyObject}, x) = PyObject(x)
69+
# These cause a LOT of method invalidations and slow down package load by a couple of
70+
# seconds. You can always use PyObject and pyconvert to go in either direction.
71+
# Base.convert(::Type{PyObject}, x::PyObject) = x
72+
# Base.convert(::Type{Any}, x::PyObject) = x
73+
# Base.convert(::Type{T}, x::PyObject) where {T} = x isa T ? x : pyconvert(T, x)
74+
# Base.convert(::Type{PyObject}, x) = PyObject(x)
7375

7476
### Cache some common values
7577

0 commit comments

Comments
 (0)