Jeremy Fincher wrote: > That's something I've always wondered about -- what exactly is a > "variable length type" and why are they special? From what I gather, > they're types (long, str, and tuple are the main ones I know of) whose > struct is actually of variable size -- rather than contain a pointer > to a variable-size thing, they contain the variable-size thing > themselves. Correct. Examples include strings and tuples, but not lists and dictionaries. > What do we gain from them? Speed, by saving an extra allocation upon creation; also some speed by saving an indirection upon access. It only works if the number of items in the object is not going to change over the lifetime of the object - in particular, for immutable objects. There is actually an exception to this rule: If you own the only reference to the object, you can afford to change its size (available for strings only). Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4