Could be a class, could be a byte, could be fml

Not really. Python doesn't have variables in the first place.

Of course it does. Whether they are on the stack or the heap is totally irrelevant to whether they are a variable.

Yes, Python's "variables" are just names for objects.

Yes, like references or pointers. std::string & x is a reference variable.

In C you'd have to use a union which will physically allocate an amount of memory that's enough to fit all the types. Python's "variables" don't care about the object's size to begin with.

If you want to use them as the actual type, they most certainly do. Underlying the fundamental (and user C API) defined python type are structs containing a PyObject HEAD and then the type specific data.

struct my_type
{
    PyObject HEAD;
    double my_data;
    int more data;
};

PyObject * foo = PyFloat_FromDouble(0.0);
my_type * x = (my_type*)foo;

... use x as my_type...

BOOM
/r/ProgrammerHumor Thread Parent Link - i.redd.it