Skip to content

Commit 32aeb7d

Browse files
committed
Merge branch 'less-getptr' into benchmarks
2 parents 9206cb2 + 5117abc commit 32aeb7d

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/Convert/ctypes.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
struct pyconvert_rule_ctypessimplevalue{R,S} <: Function end
22

33
function (::pyconvert_rule_ctypessimplevalue{R,SAFE})(::Type{T}, x::Py) where {R,SAFE,T}
4-
Base.GC.@preserve x begin
5-
ptr = C.PySimpleObject_GetValue(Ptr{R}, x)
6-
ans = unsafe_load(ptr)
7-
if SAFE
8-
pyconvert_return(convert(T, ans))
9-
else
10-
pyconvert_tryconvert(T, ans)
11-
end
4+
ptr = C.PySimpleObject_GetValue(Ptr{R}, x)
5+
ans = unsafe_load(ptr)
6+
if SAFE
7+
pyconvert_return(convert(T, ans))
8+
else
9+
pyconvert_tryconvert(T, ans)
1210
end
1311
end
1412

src/Core/Py.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pyconvert(::Type{Py}, x::Py) = x
5151

5252
setptr!(x::Py, ptr::C.PyPtr) = (setfield!(x, :ptr, ptr); x)
5353

54-
incref(x::Py) = Base.GC.@preserve x (incref(getptr(x)); x)
55-
decref(x::Py) = Base.GC.@preserve x (decref(getptr(x)); x)
54+
incref(x::Py) = (incref(getptr(x)); x)
55+
decref(x::Py) = (decref(getptr(x)); x)
5656

5757
Base.unsafe_convert(::Type{C.PyPtr}, x::Py) = getptr(x)
5858

src/Core/builtins.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ function pytuple_setitem(xs::Py, i, x)
898898
end
899899

900900
function pytuple_getitem(xs::Py, i)
901-
Base.GC.@preserve xs pynew(incref(errcheck(C.PyTuple_GetItem(xs, i))))
901+
pynew(incref(errcheck(C.PyTuple_GetItem(xs, i))))
902902
end
903903

904904
function pytuple_fromiter(xs)

src/JlWrap/io.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function pyjlbinaryio_readinto(io::IO, b::Py)
102102
return PyNULL
103103
end
104104
pydel!(c)
105-
buf = unsafe_load(C.PyMemoryView_GET_BUFFER(m))
105+
buf = unsafe_load(C.PyMemoryView_GET_BUFFER(m_))
106106
if buf.readonly != 0
107107
pydel!(m)
108108
errset(pybuiltins.ValueError, "output buffer is read-only")

0 commit comments

Comments
 (0)