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
850
0
Share
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
930
Other Decks in Programming
See All in Programming
My daily life on Ruby
a_matsuda
3
410
[BalkanRuby 2026] Drop your app/services!
palkan
3
490
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
0
240
AI時代になぜ書くのか
mutsumix
0
420
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.3k
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
160
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
620
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
510
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
370
GitHubCopilotCLIをはじめよう.pdf
htkym
0
340
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
2k
色即是空、空即是色、データサイエンス
kamoneggi
1
110
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
260
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
290
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
54k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
140
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Un-Boring Meetings
codingconduct
0
290
Optimising Largest Contentful Paint
csswizardry
37
3.7k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
370
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