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
Slide for lt-20220511
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Shinonome517
June 22, 2022
Programming
860
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slide for lt-20220511
The PDF slide for a lighting talk event at RICORA Programming Team on 2022 May 11.
Shinonome517
June 22, 2022
More Decks by Shinonome517
See All by Shinonome517
C++で末尾再帰を最適化したい / Cpp-tail-recursion-elimination
shinonome517
0
960
Other Decks in Programming
See All in Programming
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2k
AIが無かった頃の素敵な出会いの話
codmoninc
1
480
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
250
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
150
MySQLとPostgreSQLって何が違うの?
akagami
0
120
リアルな遅延を測る仕様
kota_yata
1
120
Hono + Inertia + React で LP を構築した話
oukayuka
2
110
源内ハンズオン概要編
hideg
0
200
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
0
190
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
1
150
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.9k
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
430
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
エンジニアに許された特別な時間の終わり
watany
108
250k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
430
Accessibility Awareness
sabderemane
1
180
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
290
A designer walks into a library…
pauljervisheath
211
24k
Transcript
Python のprint 関数に見 るポリモーフィズム Python のprint 関数にみるポリモーフィズム Copyright © 2022
@Shinonome517Stu 1
Python のprint 関数の挙動 どんな組み込みのオブジェクトをprint 関数の引数に与えても、 Python は綺麗に表示してくれる C++ のようなコンパイル言語ではそうはいかない Python
のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu 2
Python のprint 関数の挙動 Python のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu
3
Python のprint 関数の挙動 例えば、最も簡単にPython のprint 関数をまねる方法として「関数 オーバーロード」がある Python ののprint 関数もこれで実現されているのだろうか?
Python のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu 4
Python のprint 関数の挙動 Python のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu
5
Python のprint 関数の仕組み python のprint 関数 print(obj) は次と等価 Python のprint
関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu 6
Python のprint 関数の仕組み obj.__str__() # & 「文字列型の標準出力」 Python のprint 関数にみるポリモーフィズム
Copyright © 2022 @Shinonome517Stu 7
ポリモーフィズムとは ざっくりいうと・・・ Python のprint 関数にみるポリモーフィズム 抽象化した時に同じものを同じものとして扱うこと “ “ Copyright ©
2022 @Shinonome517Stu 8
ポリモーフィズムとは (具体例) Python のprint 関数にみるポリモーフィズム Python の「文字列」も「リスト(配列)」も「タプル」も別モノ だけれども、 同じPython オブジェクトとして抽象的に「同じPython
オブジェク トである」という扱いでコマンドラインに標準出力したい!! “ “ Copyright © 2022 @Shinonome517Stu 9
print 関数で表示できるデータ構造をつくる 人物相関図を保存するデータ構造を実装した Python のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu
10
print 関数で表示できるデータ構造を作る マジックメソッドの__str__() 関数を実装するだけで、自作メソッドを print 関数の引数として実行できるようになった Python のprint 関数にみるポリモーフィズム Copyright
© 2022 @Shinonome517Stu 11
所感 オーバーロードで実現していたら、ユーザーは気軽に拡張ができな かった。 ポリモーフィズムの考え方に則ってPython の構文や組み込み関数は 設計されている点が素晴らしいと思う。 スクリプト言語は大体このような実装がなされているのだろうか (JavaScript もそう) 動的型付けの実装に伴うものなんだろうか?(クラスが型を持つた
め) Python のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu 12
参考資料 Python 公式ドキュメント -print() 日曜プログラマーの休日 青春ブタ野郎はゆめみる少女の夢をみない - 登場人物相関図 Python のprint
関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu 13
ご清聴ありがとうございました Python のprint 関数にみるポリモーフィズム Copyright © 2022 @Shinonome517Stu 14