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
160
バックアップしていますか?
tsudaahr
0
100
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
110
NPUわからん
tsudaahr
0
160
計算量オーダーの話
tsudaahr
1
370
クラウド初学者が抱える不安について
tsudaahr
0
240
キューとは何か
tsudaahr
0
210
等幅は死んだ(ぇ
tsudaahr
0
84
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
170
Other Decks in Programming
See All in Programming
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
170
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.4k
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
6
1.7k
ふつうの技術スタックでアート作品を作ってみる
akira888
0
210
PicoRuby on Rails
makicamel
2
110
ASP.NETアプリケーションのモダナイズ インフラ編
tomokusaba
1
430
型付きアクターモデルがもたらす分散シミュレーションの未来
piyo7
0
810
CursorはMCPを使った方が良いぞ
taigakono
1
200
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
技術同人誌をMCP Serverにしてみた
74th
1
450
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
450
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
220
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
380
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Producing Creativity
orderedlist
PRO
346
40k
Documentation Writing (for coders)
carmenintech
72
4.9k
A designer walks into a library…
pauljervisheath
207
24k
It's Worth the Effort
3n
185
28k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
940
Code Review Best Practice
trishagee
69
18k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
[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
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。