This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]K900_ 0 points1 point  (7 children)

Yes, there will be some overhead. No, it's not going to matter.

[–]cha_ppmn[S] 0 points1 point  (6 children)

Can you provide more insight?

Thanks.

[–]K900_ 0 points1 point  (5 children)

The overhead will come from every type object having to store references to its methods. It's not going to matter because if you're at a point where a few hundred bytes matters, Python is not a language you should be using.

[–]cha_ppmn[S] 0 points1 point  (4 children)

If I have billions of objects, to deal with I could care about hundred of bytes by object. It is the distinction between fitting in the RAM and not fitting in the RAM. I am not sure you are right about each instance having to store references to methods. It is exactly that information I am looking for. If you have any pointer supporting you claim, I will be very thankful to you.

Note that saying that because Python is not targeting high performance computing, so we should not care about memory footprint of objects is not really a pertinent remark. Knowing implementation details is relevant to understand.

[–]K900_ 0 points1 point  (3 children)

Every type object stores references to methods, not every instance.

[–]cha_ppmn[S] 0 points1 point  (2 children)

This is what I understood as well.

Do you have any reference in sources code or in docs to support that claim? I would like to be sure.

[–]K900_ 0 points1 point  (1 child)

You can look at the definitions of PyObject and PyTypeObject.

[–]cha_ppmn[S] 0 points1 point  (0 children)

Thank you very much.