Top "Python-internals" questions

How does Python work underneath the hood?

Are sets ordered like dicts in python3.6

Due to changes in dict implementation in Python 3.6 it is now ordered by default. Do sets preserve order as well …

python set python-3.6 cpython python-internals
Why is a function/method call in python expensive?

In this post, Guido van Rossum says that a function call may be expensive, but I do not understand why …

python profiling function-calls python-internals
Two variables in Python have same id, but not lists or tuples

Two variables in Python have the same id: a = 10 b = 10 a is b >>> True If I take …

python python-3.x tuples identity python-internals
What exactly is contained within a obj.__closure__?

Beazley pg 100 mentions: >>>python.__closure__ (<cell at 0x67f50: str object at 0x69230>,) >>&…

python closures python-internals
What does "del" do exactly?

Here is my code: from memory_profiler import profile @profile def mess_with_memory(): huge_list = range(20000000) del huge_list …

python memory python-internals
Why does tuple(set([1,"a","b","c","z","f"])) == tuple(set(["a","b","c","z","f",1])) 85% of the time with hash randomization enabled?

Given Zero Piraeus' answer to another question, we have that x = tuple(set([1, "a", "b", "c", "z", "f"])) y = tuple(…

python hash set cpython python-internals
Fatal Python error and `BufferedWriter`

I've came across this paragraph in the Documentations which says: Binary buffered objects (instances of BufferedReader, BufferedWriter, BufferedRandom and BufferedRWPair) …

python linux multithreading python-2.7 python-internals
What's with the integer cache maintained by the interpreter?

After dive into Python's source code, I find out that it maintains an array of PyInt_Objects ranging from int(…

python caching code-analysis literals python-internals
About the changing id of an immutable string

Something about the id of objects of type str (in python 2.7) puzzles me. The str type is immutable, so I …

python string immutability python-internals
Randomly extract x items from a list using python

Starting with two lists such as: lstOne = [ '1', '2', '3', '4', '5', '6', '7…

python list random indices python-internals