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
技術同人誌をMCP Serverにしてみた
74th
1
660
Systèmes distribués, pour le meilleur et pour le pire - BreizhCamp 2025 - Conférence
slecache
0
120
Rails Frontend Evolution: It Was a Setup All Along
skryukov
0
160
効率的な開発手段として VRTを活用する
ishkawa
0
150
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
260
VS Code Update for GitHub Copilot
74th
2
660
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
210
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
560
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
210
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
260
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
300
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
2
150
Featured
See All Featured
Building Applications with DynamoDB
mza
95
6.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
A designer walks into a library…
pauljervisheath
207
24k
Documentation Writing (for coders)
carmenintech
72
4.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
830
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Bash Introduction
62gerente
613
210k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Faster Mobile Websites
deanohume
307
31k
Producing Creativity
orderedlist
PRO
346
40k
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 !