Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python から.net DLL を呼び出す
Search
tsuda.a
December 30, 2022
Programming
0
1.2k
Python から.net DLL を呼び出す
Python (Iron Python ではなく、普通のいわゆる cPython (ver3系)) で .net core の DLL を呼び出してみた例です。
tsuda.a
December 30, 2022
Tweet
Share
More Decks by tsuda.a
See All by tsuda.a
マジカルインクリメントと指数表記
tsudaahr
0
150
バックアップしていますか?
tsudaahr
0
100
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
110
NPUわからん
tsudaahr
0
160
計算量オーダーの話
tsudaahr
1
370
クラウド初学者が抱える不安について
tsudaahr
0
230
キューとは何か
tsudaahr
0
210
等幅は死んだ(ぇ
tsudaahr
0
83
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
170
Other Decks in Programming
See All in Programming
Webからモバイルへ Vue.js × Capacitor 活用事例
naokihaba
0
460
OpenNext + Hono on Cloudflare でイマドキWeb開発スタックを実現する
rokuosan
0
120
プロダクト開発でも使おう 関数のオーバーロード
yoiwamoto
0
140
Gleamという選択肢
comamoca
6
640
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
110
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
200
ワイがおすすめする新潟の食 / 20250530phpconf-niigata-eve
kasacchiful
0
290
事業戦略を理解してソフトウェアを設計する
masuda220
PRO
21
5.7k
ReadMoreTextView
fornewid
0
240
ドメインモデリングにおける抽象の役割、tagless-finalによるDSL構築、そして型安全な最適化
knih
10
1.7k
Elixir で IoT 開発、 Nerves なら簡単にできる!?
pojiro
1
100
💎 My RubyKaigi Effect in 2025: Top Ruby Companies 🌐
yasulab
PRO
1
130
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Visualization
eitanlees
146
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Optimizing for Happiness
mojombo
379
70k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Scaling GitHub
holman
459
140k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Transcript
Python から .net DLL を 呼び出す すごい広島 .rb with Python[69]
オンライン LTDD 2022-12 #1 @tsuda_ahr
準備 pip install pythonnet ※ .net core のインストールは済んでいるものとします
Visual Studio で dll を作成 (.net core で作ります) namespace PythonTestNamespace
{ public class PythonTestClass { public int Add(int value1, int value2) { return value1 + value2; } } }
Python のコードを書く from pythonnet import load Load(“coreclr”) import clr clr.AddReference('PythonTest')
from PythonTestNamespace import PythonTestClass test = PythonTestClass() ver = test.Add(1, 2) print(ver) .net core の CLR を使用 (これを書かないと .net framework になる) DLL を Load Class を Import
同じフォルダに配置
実行
よって ライブラリロジックは C# で書いて、それを Python で操ることが可能!
そんなことをして何が楽しいのか?
Powershell (pwsh) からでも使えるよ!
C# DLL WindowsApp Python Powershell Excel VBA つまりいろんな環境から呼び出せる。 Winows Only
Winows or Linux or Mac
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。