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
230
バックアップしていますか?
tsudaahr
0
140
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
140
NPUわからん
tsudaahr
0
200
計算量オーダーの話
tsudaahr
1
430
クラウド初学者が抱える不安について
tsudaahr
0
310
キューとは何か
tsudaahr
0
260
等幅は死んだ(ぇ
tsudaahr
0
120
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
210
Other Decks in Programming
See All in Programming
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
3
2k
The free-lunch guide to idea circularity
hollycummins
0
350
脱 雰囲気実装!AgentCoreを良い感じにWEBアプリケーションに組み込むために
takuyay0ne
3
400
へんな働き方
yusukebe
6
2.8k
今年もTECHSCOREブログを書き続けます!
hiraoku101
0
130
Nostalgia Meets Technology: Super Mario with TypeScript
manfredsteyer
PRO
0
110
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
1.4k
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
290
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
230
今こそ押さえておきたい アマゾンウェブサービス(AWS)の データベースの基礎 おもクラ #6版
satoshi256kbyte
1
190
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
290
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
190
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
480
Unsuck your backbone
ammeep
672
58k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
160
The Curse of the Amulet
leimatthew05
1
10k
Building Applications with DynamoDB
mza
96
7k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
190
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
660
A Tale of Four Properties
chriscoyier
163
24k
Odyssey Design
rkendrick25
PRO
2
560
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
デメリット? • たぶん激烈に遅い(計測はしていません)
ご清聴ありがとうございました。