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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
tsuda.a
December 30, 2022
Programming
0
1.3k
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
220
バックアップしていますか?
tsudaahr
0
130
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
130
NPUわからん
tsudaahr
0
190
計算量オーダーの話
tsudaahr
1
410
クラウド初学者が抱える不安について
tsudaahr
0
290
キューとは何か
tsudaahr
0
250
等幅は死んだ(ぇ
tsudaahr
0
110
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
200
Other Decks in Programming
See All in Programming
[AI Engineering Summit Tokyo 2025] LLMは計画業務のゲームチェンジャーか? 最適化業務における活⽤の可能性と限界
terryu16
2
440
CSC307 Lecture 06
javiergs
PRO
0
650
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
140
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.2k
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
520
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
550
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
380
AgentCoreとHuman in the Loop
har1101
5
200
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
230
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
120
Fragmented Architectures
denyspoltorak
0
140
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
5
4.2k
Featured
See All Featured
Faster Mobile Websites
deanohume
310
31k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
71k
Balancing Empowerment & Direction
lara
5
850
Skip the Path - Find Your Career Trail
mkilby
0
47
30 Presentation Tips
portentint
PRO
1
190
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Agile that works and the tools we love
rasmusluckow
331
21k
Believing is Seeing
oripsolob
1
38
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
110
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
A better future with KSS
kneath
240
18k
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
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。