Most voted "cpython" questions
Use this tag only when the question deals with details regarding the Cpython implementation. When referring to language details, use the python tag.
Learn more…8 questions
Sort by count of
-
12
votes1
answer161
viewsWhy does 2*i*i tend to be faster than 2*(i*i) when i is integer?
The two multiplications, 2*i*i and 2*(i*i), are equal and must generate the same result, what changes is only the order that the multiplications are made, but apparently are treated differently by…
-
11
votes1
answer374
viewsDoes multiple assignment in Python use tuples?
In the question Inverting two variables without using a temporary an answer quotes a link that comments on the multiple assignment of variables in Python: Functioning of Multiple Assignment The…
-
9
votes3
answers566
viewsHow does Python handle and represent an array internally?
In Python any type of array is of class type list, see: array = ['Gato', 'Jake', 'Finn'] print(type(array)) Exit: <class 'list'> That is, every array is an object of list. However, there is…
python array characteristic-language python-internals cpythonasked 5 years, 10 months ago gato 22,329 -
8
votes1
answer147
viewsWhy do these two ways of initializing the same list in Python generate structures of different sizes?
It is common to need to initialize a list in Python with a defined amount of elements and we can do this in two ways: 1) multiplying the list with an element by the desired amount; or 2) using the…
-
6
votes1
answer669
viewsWhy do formatting options not work with lists, dictionaries, and other objects?
When I want to print a number or string, I can use f-strings (in Python >= 3.6) or str.format, and I can only pass the variable between keys, or use the formatting options. Ex: numero, texto =…
python python-3.x characteristic-language python-internals cpythonasked 4 years, 7 months ago hkotsubo 55,826 -
1
votes2
answers350
viewsFonts for standard Python functions
Is there any way I can figure out the algorithm behind functions like split() and in in Python, because in my faculty there are some forbidden functions.
-
1
votes1
answer85
viewsWhat is the purpose of the "Pyobject" structure and what are the objectives of its members?
I’m analyzing the structure Pyobject of Cpython. The code for this structure follows below. Structure PyObject: typedef struct _object { _PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt; struct _typeobject…
-
0
votes1
answer61
viewsHow does the declaration of a class in Python handle the external scope?
To illustrate, let’s consider this class statement: x = 1 class Foo: a = x b = [x] c = [x for _ in range(1)] print(f'x = {x}') # x = 1 print(f'Foo.a = {Foo.a}') # Foo.a = 1 print(f'Foo.b = {Foo.b}')…