search

Home  >  Q&A  >  body text

python package `from _collections import deque, defaultdict`

I saw this line of code by chance yesterday
from _collections import deque

I was looking at the python library documentation. When I saw collections, I went to find the source code of deque.
Then I looked for _collections, but it was not found in the Lib directory. Use the search file When I found the directory
Lib/site-packages/requests/packages/urllib3/_collections.py , but there was no code about deque in it, so I was curiousfrom _collections import deque, where did this _collections come from

某草草某草草2753 days ago846

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-05-18 10:51:24

    here

    https://github.com/python/cpy...

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-18 10:51:24

    Built-in module, similar to c extension

    In [4]: ​​import _collections

    In [5]: _collections
    Out[5]: <module '_collections' (built-in)>

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-18 10:51:24

    _collections是一个内置模块, 要从源码查找: Python-2.7.12/Modules/_collectionsmodule.c

    reply
    0
  • Cancelreply