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
"String intern" を知ってますか?
Search
skokado
October 14, 2022
Programming
0
180
"String intern" を知ってますか?
20221014_PyConJP2022_LT
skokado
October 14, 2022
Tweet
Share
More Decks by skokado
See All by skokado
ポートフォリオページの公開にGitLab CI/CDを使っている話
skokado
4
2k
Other Decks in Programming
See All in Programming
Swift Updates - Learn Languages 2025
koher
2
510
個人軟體時代
ethanhuang13
0
330
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
710
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
350
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
Kiroで始めるAI-DLC
kaonash
2
620
Performance for Conversion! 分散トレーシングでボトルネックを 特定せよ
inetand
0
2.4k
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
510
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
2.5k
AWS発のAIエディタKiroを使ってみた
iriikeita
1
190
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.3k
はじめてのMaterial3 Expressive
ym223
2
900
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
RailsConf 2023
tenderlove
30
1.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Optimizing for Happiness
mojombo
379
70k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.1k
Transcript
“String intern” を知ってますか? 2022/10/14 @ PyCon JP 2022 LT
• 小門 照太 ◦ https://portfolio.skokado.me/ • 職種:インフラ / クラウドエンジニア •
所属:株式会社RevComm • Python, AWS, DevOps, … • 小鳥+猫 自己紹介
(再掲) “String intern” を知ってますか? 2022/10/14 @ PyCon JP 2022 LT
クイズです
次のうち is による比較結果が True になるのはどれでしょう? クイズです
次のうち is による比較結果が True になるのはどれでしょう? クイズです
次のうち is による比較結果が True になるのはどれでしょう? ⇒Answer: 1, 2, 3 クイズです
次のうち is による比較結果が True になるのはどれでしょう? ⇒Answer: 1, 2, 3 ※補足
- Python 3.10.6 - 対話モードで実行する場合 - 右の記法では True クイズです
“String intern” なぜか
メモリー内の “隔離” されたテーブルに文字列の値のコピーを格納する仕組み What is “String intern” ?
メモリー内の “隔離” されたテーブルに文字列の値のコピーを格納する仕組み What is “String intern” ? 文字列 PyConJP
が “intern” された
メモリー内の “隔離” されたテーブルに文字列の値のコピーを格納する仕組み メリット • 値が同じ変数同士を比較する場合のパフォーマンス向上 ◦ 文字列の値ではなくポインタで比較可能になるため What is
“String intern” ?
しかし、メモリー使用量やオーバーヘッドのトレードオフがある。 そのため「全ての文字列を intern する」わけではない。 ⇒Python はいくつかのルールに基づいて intern を行う ※「いくつかのルール」のドキュメントは見つけられず …
What is “String intern” ?
しかし、メモリー使用量やオーバーヘッドのトレードオフがある。 そのため「全ての文字列を intern する」わけではない。 ⇒Python はいくつかのルールに基づいて intern を行う ※「いくつかのルール」のドキュメントは見つけられず …
What is “String intern” ?
intern を強制することが可能 sys.intern()
「長い文字列の比較」においてパフォーマンスが向上する 使いどころ
「長い文字列の比較」においてパフォーマンスが向上する 使いどころ
リンク • String Interning in Python: A Hidden Gem That
Makes Your Code Faster Appendix
Thank you !