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
220
0
Share
"String intern" を知ってますか?
20221014_PyConJP2022_LT
skokado
October 14, 2022
More Decks by skokado
See All by skokado
ポートフォリオページの公開にGitLab CI/CDを使っている話
skokado
4
2.1k
Other Decks in Programming
See All in Programming
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
120
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.6k
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
120
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.5k
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.3k
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
210
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
250
AIと共に生きる技術選定 2026
sgash708
0
120
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
480
Agentic Elixir
whatyouhide
0
440
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.5k
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
120
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Practical Orchestrator
shlominoach
191
11k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
290
Automating Front-end Workflow
addyosmani
1370
200k
Building Adaptive Systems
keathley
44
3k
Scaling GitHub
holman
464
140k
So, you think you're a good person
axbom
PRO
2
2k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
28
Prompt Engineering for Job Search
mfonobong
0
290
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Technical Leadership for Architectural Decision Making
baasie
3
350
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 !