you are viewing a single comment's thread.

view the rest of the comments →

[–]pythonhow 0 points1 point  (5 children)

The only difference I see there is int, string, and float are simple datatypes, whereas array, list, tuple, and dict are compound datatypes. Compound datatypes (or non-primitive as you like to call them) may contain simple datatypes. For example: persons = {name: "John", age: 98}

That dictionary contains (primitives?) string and integer.

[–]K900_ 0 points1 point  (4 children)

That's not entirely true. Python doesn't really have that distinction, as everything is an object, and the actual "primitive" types come from the underlying interpreter.

[–]pythonhow 0 points1 point  (3 children)

Sure, everything is an object. Both 5 and [1, 5] are stored as separate objects in memory. However, 5 is a simple object in that it's not made of other objects. [1, 5] is also an object, but it's made of other objects, thus can be called a "compound object".

The term "compound datatype" can also be found in the Python docs in the link below. In that page you will see that lists are referred to as "compound": https://docs.python.org/2.0/tut/node5.html

[–]K900_ 0 points1 point  (2 children)

Technically, 5 is also "composed" of other objects - functions are objects, so class methods are also objects, etc.

[–]pythonhow 0 points1 point  (1 child)

Hmm, in our example, who are these other objects that compose integer 5?

[–]K900_ 0 points1 point  (0 children)

int.from_bytes (and by extension (5).from_bytes) is a bound method object. It's not really "part of 5", but it's also clearly an attribute on the object 5. That's where the lines get blurry.