突然之间想到查询一下 Python 中 sort 是使用何种算法实现, goole 之在 stackoverflow 中找到如下了回答

about-pythons-built-in-sort-method

回答中给出了源文件的链接,可以看到如图的注释.

/* Lots of code for an adaptive, stable, natural mergesort.  There are many
 * pieces to this algorithm; read listsort.txt for overviews and details.
 */

参考 :

使用了自适应的mergesort.

顺便总结一下查看Python代码和文档的方法.

参考stackoverflow中的回答

对于build-in-functions,可以采用

  •     print object.file
  •     使用inspect模块 (官方文档)

同时,可以在 http://svn.python.orghttp://hg.python.org 中查找对应代码.

在ipython中使用 function?function?? 可以查看到一些信息

shell 中使用 pydoc 可以查看对应文档