Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Python型チェッカー ty を使ってみた話
Search
nogawanogawa
May 30, 2025
2k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python型チェッカー ty を使ってみた話
nogawanogawa
May 30, 2025
More Decks by nogawanogawa
See All by nogawanogawa
Amazon Bedrockを用いた新着募集のモデレーション半自動化への取り組み
nogawanogawa
2
350
推薦システムにおけるPost Processの取り組み
nogawanogawa
2
590
Devinを導入してドキュメンテーションで変わったこと
nogawanogawa
2
210
相互推薦システム開発の舞台裏と今後の展望
nogawanogawa
2
440
コサイン類似度のいろんな書き方
nogawanogawa
4
1.7k
機械学習で使用しているGCSの料金を激減させた話
nogawanogawa
2
5.6k
How to Index Item IDs for Recommendation Foundation Models
nogawanogawa
0
680
CommonLitコンペで学んだこと
nogawanogawa
2
2.5k
Featured
See All Featured
Done Done
chrislema
187
17k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Mobile First: as difficult as doing things right
swwweet
225
10k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
47k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Amusing Abliteration
ianozsvald
1
360
The agentic SEO stack - context over prompts
schlessera
0
980
A Tale of Four Properties
chriscoyier
163
24k
Building an army of robots
kneath
307
47k
ラッコキーワード サービス紹介資料
rakko
5
5.5M
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Transcript
© 2025 Wantedly, Inc. Python型チェッカー ty を 使ってみた話 みんなのPython勉強会#114 May.30
2025 - @nogawanogawa
© 2025 Wantedly, Inc. 自己紹介 - 角川拓也 - X: @nogawanogawa
- 所属 - ウォンテッドリー株式会社 データサイエンティスト - ex. - ITコンサル @コンサル会社 - システムエンジニア @金融系SIer
© 2025 Wantedly, Inc. Pythonとデータ型
© 2025 Wantedly, Inc. Pythonとデータ型 - Pythonは動的型付け言語 - 変数の中に型情報が埋め込まれており、データ型を指定しなくても動作可能 -
「小さなプログラムでは動的型付けはすばらしい。しかし、大規模なプログラムではもっと 規律の取れたアプローチが必要である」 - データ型は保守性の高いコードの大黒柱 - Pythonでは型アノテーションによって型ヒントを付与することが可能 - 実行時には型ヒントは全く利用されないものの、ロバストなコードベースを構築するには型 ヒントは非常に有効 参考:『ロバストPython ―クリーンで保守しやすいコードを書く』オライリー・ジャパン( 2023)
© 2025 Wantedly, Inc. Python型チェッカー - Python型チェッカーが広く使われている - mypy -
Pyre - Pyright - PyType - … - コードベースが巨大になると型チェックの時間が無視できなくなるとの指摘 がある - コードの差分のみをチェックするなど、通常高速化の工夫が取られている - Python型チェッカーでは 高速化が大きなポイントになっている
© 2025 Wantedly, Inc. tyについて
© 2025 Wantedly, Inc. ty - Astral製のPython型チェッカー - ruff や
uvを開発している会社が開発 - 開発コードネームはRed-Knotらしいです - 特徴 - まだプレビュー版なのでプロダクションで使用する準備は整っていないと記載あり - 処理速度が速い - salsaというrust-analyzerでも使われているオンデマンド計算のためのフレームワーク を採用 参考: https://github.com/astral-sh/ty
© 2025 Wantedly, Inc. ty - ty check [チェック対象] で実行
- 型アノテーションが間違っている場合などには、違反箇所を教えてくれる 参考: https://github.com/astral-sh/ty
© 2025 Wantedly, Inc. 速度比較 - 簡単な速度比較をしてみる - mypyの10倍近く高速化 -
mypyはキャッシュが効いているはずだがそれでも tyのほうが圧倒的に速い この事例では 10倍ほど高速化 参考: https://www.nogawanogawa.work/entry/ty
© 2025 Wantedly, Inc. • 保守性の高いPythonコードベースには型アノテーションが重要と言われる ◦ そのためにPython型チェッカーが広く使われている ◦ 型チェッカーのポイントの一つとして速度が注目されてきた
• Python型チェッカー ty ◦ rustのsalsaフレームワークをベースにしており非常に高速 • 速度比較 ◦ 簡易実験してみたところ、mypyより高速だった まとめ