py3源码[4]-字符串
py2.x中的字符串已经被分析的比较透彻了:
- 不可变对象
- intern,单(空)字符缓冲池:复用不可变对象;interned为pydict,new出来一个字符串的时候先查询它。
- join VS +:join高性能;format % values高性能;+低性能。
- unicode:留意当前的“默认编码”;UCS2;“encode 用于将 “默认编码” 的字符串转换为其他编码,而 decode 则还原为 Unicode”。
TODO:
In py3, Everything you thought you knew about binary data and Unicode has changed.
http://docs.python.org/3/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit
http://woodpecker.org.cn/diveintopython3/strings.html
leave a comment