Skip to content

Commit 6ad2873

Browse files
committed
1 parent aaabb68 commit 6ad2873

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Time for a ChangeLog!
2+
23
## 2.026 - UNRELEASED
34
* Faster string conversion from c->jvm for large strings.
45

deps.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{:paths ["src"]
22
:deps {org.clojure/clojure {:mvn/version "1.11.1" :scope "provided"}
3-
cnuernber/dtype-next {:mvn/version "10.111"}
3+
cnuernber/dtype-next {:mvn/version "10.124"}
44
net.java.dev.jna/jna {:mvn/version "5.12.1"}
55
org.clojure/data.json {:mvn/version "1.0.0"}
66
;;Replace me with caffeine...

src/libpython_clj2/python.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ user> (py/py. np linspace 2 3 :num 10)
413413
(cond
414414
(instance? IFn pyobj)
415415
true
416-
(dtype-ffi/convertible-to-pointer? pyobj)
416+
(py-ffi/convertible-to-pointer? pyobj)
417417
(py-ffi/with-gil
418418
(let [retval (long (py-ffi/PyCallable_Check pyobj))]
419419
(case retval

src/libpython_clj2/python/base.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@
8080
(extend-type Object
8181
py-proto/PCopyToJVM
8282
(->jvm [item options]
83-
(if (dt-ffi/convertible-to-pointer? item)
83+
(if (py-ffi/convertible-to-pointer? item)
8484
(py-proto/pyobject->jvm item options)
8585
;;item is already a jvm object
8686
item))
8787
py-proto/PBridgeToJVM
8888
(as-jvm [item options]
89-
(if (dt-ffi/convertible-to-pointer? item)
89+
(if (py-ffi/convertible-to-pointer? item)
9090
(py-proto/pyobject-as-jvm item options)
9191
item))
9292
py-proto/PPyCallable

src/libpython_clj2/python/bridge_as_jvm.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
(get-attr [item# item-name#]
180180
(with-gil
181181
(-> (py-proto/get-attr @pyobj*# item-name#)
182-
py-base/as-jvm)))
182+
(py-base/as-jvm))))
183183
(set-attr! [item# item-name# item-value#]
184184
(with-gil
185185
(py-ffi/with-decref [item-value# (py-ffi/untracked->python
@@ -225,7 +225,7 @@
225225
(py-base/->jvm (py-fn/call-attr @pyobj*# "__str__" nil))))))
226226
(equals [this# other#]
227227
(boolean
228-
(when (dt-ffi/convertible-to-pointer? other#)
228+
(when (py-ffi/convertible-to-pointer? other#)
229229
(py-base/equals? @pyobj*# other#))))
230230
(hashCode [this#]
231231
(.hashCode ^Object (py-base/hash-code this#)))

src/libpython_clj2/python/ffi.clj

+10
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,16 @@ Each call must be matched with PyGILState_Release"}
323323
:pyobject [{:name :ob_refcnt :datatype (ffi-size-t/size-t-type)}
324324
{:name :ob_type :datatype (ffi-size-t/size-t-type)}])))
325325

326+
327+
(defn convertible-to-pointer?
328+
"Older definition - excludes Long objects which were made convertible-to-pointer
329+
in later versions of dtype-next."
330+
[d]
331+
(boolean
332+
(when-not (instance? Long d)
333+
(dt-ffi/convertible-to-pointer? d))))
334+
335+
326336
(defn pytype-offset
327337
^long []
328338
(first (dt-struct/offset-of @pyobject-struct-type* :ob_type)))

0 commit comments

Comments
 (0)