{"id":19288364,"url":"https://github.com/techascent/tech.python","last_synced_at":"2025-10-11T11:04:52.275Z","repository":{"id":66590144,"uuid":"187280842","full_name":"techascent/tech.python","owner":"techascent","description":"Python support for the techascent ecosystem","archived":false,"fork":false,"pushed_at":"2019-05-18T00:35:51.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-05T23:35:31.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techascent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-17T20:59:21.000Z","updated_at":"2020-05-12T16:40:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"31c68d1b-e3ed-47fd-b666-43e2ff78b298","html_url":"https://github.com/techascent/tech.python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/techascent/tech.python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techascent%2Ftech.python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techascent%2Ftech.python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techascent%2Ftech.python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techascent%2Ftech.python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techascent","download_url":"https://codeload.github.com/techascent/tech.python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techascent%2Ftech.python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268393946,"owners_count":24243322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T22:08:49.182Z","updated_at":"2025-10-11T11:04:47.243Z","avatar_url":"https://github.com/techascent.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tech.python\n\nTechascent bindings to the python ecosystem.\n\n## Installation\n\n```console\nchrisn@chrisn-dt:~/dev/cnuernber/libpython-clj$ sudo update-alternatives --config java\n[sudo] password for chrisn:\nThere are 2 choices for the alternative java (providing /usr/bin/java).\n\n  Selection    Path                                            Priority   Status\n  ------------------------------------------------------------\n    0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode\n    1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode\n  * 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode\n\n  Press \u003center\u003e to keep the current choice[*], or type selection number: ^C\nchrisn@chrisn-dt:~/dev/cnuernber/libpython-clj$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ pip3 install jep --user\n```\n\n\n## Usage\n\n```clojure\n\n;;Create a thread-local interpreter\nuser\u003e (import '[jep Jep])\njep.Jep\nuser\u003e (def myjep (Jep.))\n#'user/myjep\n\n;;Eval some code.  The only way to read data out is to assign results to variables.\nuser\u003e (.eval myjep \"t = [object(), 1, 1.5, True, None, [], (), {'key':'value'} ]\")\ntrue\nuser\u003e (import '[jep.python PyObject])\njep.python.PyObject\nuser\u003e (.getValue myjep \"t\", (Class/forName \"[Ljep.python.PyObject;\"))\n[#object[jep.python.PyObject 0x503a2bed \"\u003cobject object at 0x7fb85bac4150\u003e\"],\n #object[jep.python.PyObject 0x447ae3e4 \"1\"],\n #object[jep.python.PyObject 0x1eb0fd33 \"1.5\"],\n #object[jep.python.PyObject 0xd9e632a \"True\"], nil,\n #object[jep.python.PyObject 0x58c4bd1d \"[]\"],\n #object[jep.python.PyObject 0x4b321022 \"()\"],\n #object[jep.python.PyObject 0x52723512 \"{'key': 'value'}\"]]\n\n\n;; Some basics\n\nuser\u003e (import [java.util HashMap])\njava.util.HashMap\nuser\u003e (.set myjep \"t\" (HashMap. {\"one\" 1 \"two\" 2}))\nnil\nuser\u003e (.eval myjep \"b = t[\\\"one\\\"]\")\ntrue\nuser\u003e (.getValue myjep \"b\")\n1\nuser\u003e (.set myjep \"t\" (vec (reverse (range 10))))\nnil\nuser\u003e (.eval myjep \"b = t[2:2]\")\ntrue\nuser\u003e (.getValue myjep \"b\")\n[]\nuser\u003e (.eval myjep \"b = t[2:4]\")\ntrue\nuser\u003e (.getValue myjep \"b\")\n[7 6]\n\n\n;;Lets get into some numpy.  Jep has support for this through their\n;;ndarray objects.  Tech has support via a protocols.  NDArrays are first\n;;class citizens if you require the right namespace: [tech.libs.jep.ndarray]\n\nuser\u003e (.eval myjep \"import numpy as np\")\ntrue\nuser\u003e (.eval myjep \"t = np.ones((2,3))\")\ntrue\nuser\u003e (.getValue myjep \"t\")\n#object[jep.NDArray 0x5bcc9658 \"jep.NDArray@2de134a2\"]\nuser\u003e (require '[tech.libs.jep.ndarray])\n:tech.resource.gc Reference thread starting\nuser\u003e (require '[tech.v2.datatype :as dtype])\nnil\nuser\u003e (def test-np-ary (.getValue myjep \"t\"))\n#'user/test-np-ary\nuser\u003e (dtype/shape test-np-ary)\n[2 3]\nuser\u003e (require '[tech.v2.tensor :as dtt])\nnil\n\n;; ND arrays have zero-copy conversion to tensors.\nuser\u003e (println (dtt/ensure-tensor test-np-ary))\n#tech.v2.tensor\u003cfloat64\u003e[2 3]\n[[1.000 1.000 1.000]\n [1.000 1.000 1.000]]\nnil\n\n;; But let's say you want to create your own tensor outside of this context.\nuser\u003e (def test-tensor (dtt/-\u003etensor (partition 3 (range 9))))\n#'user/test-tensor\nuser\u003e (require '[tech.libs.jep.protocols :as jep-proto])\nnil\nuser\u003e (jep-proto/as-nd-array test-tensor)\n#object[jep.NDArray 0x348e8765 \"jep.NDArray@34c4baa3\"]\nuser\u003e (def test-tensor (dtt/-\u003etensor (partition 3 (range 9))\n                                     :container-type :native-buffer))\n19-05-17 23:48:51 chrisn-lt-2 INFO [tech.jna.timbre-log:8] - Library c found at [:system \"c\"]\n\n\n;; If you create a native-backed tensor then it will be a directndarray\nuser\u003e (jep-proto/as-nd-array test-tensor)\n#object[jep.DirectNDArray 0x1f904cd8 \"jep.DirectNDArray@c3d4179f\"]\nuser\u003e (.set myjep \"t\" (jep-proto/as-nd-array test-tensor))\nnil\nuser\u003e (.eval myjep \"t = t + 2\")\ntrue\n\n\n;;The results do not mirror back which means t was reallocated.\nuser\u003e (println test-tensor)\n#tech.v2.tensor\u003cfloat64\u003e[3 3]\n[[0.000 1.000 2.000]\n [3.000 4.000 5.000]\n [6.000 7.000 8.000]]\nnil\n\n\n;;That being said, the values did transfer\n\nuser\u003e (.eval myjep \"b = str(t)\")\ntrue\nuser\u003e (.getValue myjep \"b\")\n\"[[ 2.  3.  4.]\\n [ 5.  6.  7.]\\n [ 8.  9. 10.]]\"\n\n\n;;Reset t as the original test tensor object.\nuser\u003e (.set myjep \"t\" (jep-proto/as-nd-array test-tensor))\n\n;; Modifications do in fact work the other direction though\nuser\u003e (require '[tech.v2.datatype.functional :as dfn])\nnil\n;;We change the underlying values of the test tensor buffer via realizing\n;;a lazy reader chain with copy.\nuser\u003e (dtype/copy! (dfn/+ test-tensor 4) test-tensor)\n...\nuser\u003e (println test-tensor)\n#tech.v2.tensor\u003cfloat64\u003e[3 3]\n[[ 4.000  5.000  6.000]\n [ 7.000  8.000  9.000]\n [10.000 11.000 12.000]]\nnil\nuser\u003e (.eval myjep \"b = str(t)\")\ntrue\n\n;; Python does in fact reflect the values.\nuser\u003e (.getValue myjep \"b\")\n\"[[ 4.  5.  6.]\\n [ 7.  8.  9.]\\n [10. 11. 12.]]\"\nuser\u003e\n```\n\n\n## License\n\nCopyright © 2019 TechAscent, LLC\n\nThis program and the accompanying materials are made available under the\nterms of the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechascent%2Ftech.python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechascent%2Ftech.python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechascent%2Ftech.python/lists"}