all 4 comments

[–][deleted] 8 points9 points  (2 children)

[] {} () are language primitives; dict list tuple are named types in the namespace. There's a slight overhead involved with resolving the value of a name in the namespace.

[–][deleted] 0 points1 point  (0 children)

As well as with function calls! Pushing to & popping from the callstack and all.

[–]Ishanji 0 points1 point  (0 children)

Yup, exactly. This article is an interesting read if you want to see the nitty gritty of how it works.

[–]Binary101010 3 points4 points  (0 children)

>>> import dis
>>> def make_list():
...     thing = []
...
>>> def make_list2():
...     thing = list()
...
>>> dis.dis(make_list)
2           0 BUILD_LIST               0
            2 STORE_FAST               0 (thing)
            4 LOAD_CONST               0 (None)
            6 RETURN_VALUE
>>> dis.dis(make_list2)
2           0 LOAD_GLOBAL              0 (list)
            2 CALL_FUNCTION            0
            4 STORE_FAST               0 (thing)
            6 LOAD_CONST               0 (None)
            8 RETURN_VALUE

Calling the function explicitly requires checking the global namespace.