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.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
200
バックアップしていますか?
tsudaahr
0
120
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
130
NPUわからん
tsudaahr
0
180
計算量オーダーの話
tsudaahr
1
390
クラウド初学者が抱える不安について
tsudaahr
0
270
キューとは何か
tsudaahr
0
230
等幅は死んだ(ぇ
tsudaahr
0
100
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
180
Other Decks in Programming
See All in Programming
なんでRustの環境構築してないのにRust製のツールが動くの? / Why Do Rust-Based Tools Run Without a Rust Environment?
ssssota
14
47k
CSC509 Lecture 07
javiergs
PRO
0
250
ネストしたdata classの面倒な更新にさようなら!Lensを作って理解するArrowのOpticsの世界
shiita0903
1
210
オープンソースソフトウェアへの解像度🔬
utam0k
18
3.2k
AI駆動開発カンファレンスAutumn2025 _AI駆動開発にはAI駆動品質保証
autifyhq
0
100
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
250
ドメイン駆動設計のエッセンス
masuda220
PRO
15
7.1k
AsyncSequenceとAsyncStreamのプロポーザルを全部読む!!
s_shimotori
1
220
Ktorで簡単AIアプリケーション
tsukakei
0
120
Kotlinで実装するCPU/GPU 「協調的」パフォーマンス管理
matuyuhi
0
160
マンガアプリViewerの大画面対応を考える
kk__777
0
440
AIのバカさ加減に怒る前にやっておくこと
blueeventhorizon
0
130
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Site-Speed That Sticks
csswizardry
13
940
Building Flexible Design Systems
yeseniaperezcruz
329
39k
How to train your dragon (web standard)
notwaldorf
97
6.3k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
940
Designing for Performance
lara
610
69k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Navigating Team Friction
lara
190
15k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6k
Git: the NoSQL Database
bkeepers
PRO
431
66k
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
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。