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
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
"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
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
810
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
120
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
110
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
350
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
340
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
140
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
110
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
130
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
4
2.7k
What We Talk About When We Talk About XP
m_seki
2
310
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
500
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
990
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
The Curious Case for Waylosing
cassininazir
1
490
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
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 !