3 ms·
No. I even believe that non-builtin types behaving like numbers might use operators. But lists, arrays, strings behave not like numbers. They allocate memory, t
by ordu 5y ago
No. I even believe that non-builtin types behaving like numbers might use operators. But lists, arrays, strings behave not like numbers. They allocate memory, they reuse memory for values, they have operations of non O(1) complexity, and so they shouldn't be using operators. If one really wants to, then he might invent new operators for this, like concatenation-operator. I didn't see any reasonable way to do it, but it doesn't mean that such way cannot be devised.
- c-cube 5y agoNumbers in python also allocate memory. Integers are arbitrary precision, so the difference between + and += might also be very relevant for them. And of course there's numpy and matrices which also behave like numbers, or at least like mathematical objects.