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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
tsuda.a
December 30, 2022
Programming
1.3k
0
Share
Python から.net DLL を呼び出す
Python (Iron Python ではなく、普通のいわゆる cPython (ver3系)) で .net core の DLL を呼び出してみた例です。
tsuda.a
December 30, 2022
More Decks by tsuda.a
See All by tsuda.a
マジカルインクリメントと指数表記
tsudaahr
0
230
バックアップしていますか?
tsudaahr
0
140
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
150
NPUわからん
tsudaahr
0
200
計算量オーダーの話
tsudaahr
1
440
クラウド初学者が抱える不安について
tsudaahr
0
310
キューとは何か
tsudaahr
0
270
等幅は死んだ(ぇ
tsudaahr
0
120
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
210
Other Decks in Programming
See All in Programming
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
170
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
360
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.3k
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
160
へんな働き方
yusukebe
6
2.9k
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
990
Don't Prompt Harder, Structure Better
kitasuke
0
640
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
9
5.2k
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
540
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
750
まかせられるPM・まかせられないPM / DevTech GUILD Meetup
yusukemukoyama
0
110
AIエージェントで業務改善してみた
taku271
0
500
Featured
See All Featured
Building an army of robots
kneath
306
46k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Side Projects
sachag
455
43k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
370
Speed Design
sergeychernyshev
33
1.6k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
190
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
How to build a perfect <img>
jonoalderson
1
5.4k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
140
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Making Projects Easy
brettharned
120
6.6k
Ruling the World: When Life Gets Gamed
codingconduct
0
190
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
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。