擅长:python、mysql、java
<p>如果您查看python字符串实现,您会发现releavent行:</p>
<pre><code>op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size);
</code></pre>
<p>这表明字符串是使用python的malloc简单地分配的。它们不像整数那样使用池,因为python字符串对象的大小取决于字符串的长度。所以不能像对待整数那样使用池。在</p>
<p>参见:<a href="http://www6.uniovi.es/python/dev/src/c/html/stringobject_8c-source.html" rel="nofollow">http://www6.uniovi.es/python/dev/src/c/html/stringobject_8c-source.html</a></p>