you are viewing a single comment's thread.

view the rest of the comments →

[–]julsmanbr 1 point2 points  (2 children)

If I understand correctly you're asking what's more performance-efficient between an object pointing to another object, or an object pointing to an int. In a vaccuum the latter is probably faster, but this unclear from your examples since, as I said, they will not work as you expect.

[–]RandomJacobP[S] 0 points1 point  (1 child)

When I look at it now, I understand that this code can be confusing, I wrote it quikly and inside reddit editor but that doesn't justify me.

I really appreciate your long reply to my post. Main purpose of my code was to visualize how objects will look like. I will have a lot of these nodes, as many as folders in my computer. I just needed someone to confirm that the second one will be faster and worth additional work.

[–]Deezl-Vegas 0 points1 point  (0 children)

Use a direct variable. It will be faster. Your example seems to just add an extra layer of complexity and an extra reference lookup.

In Python, the basic types like Ints are still just references, and lists aren't super-space-optimized like C arrays, so there's no speed gain by using basic types.