Re: Need clarification on empty arrays and alocated space

new topic     » goto parent     » topic index » view thread      » older message » newer message

Replying for Phix:

jpartridge said...

Are OEu empty arrays a different type like the 'slices' in Go?
Do these 'slices' need a backup array with a certain predefined size?

No and no.

jpartridge said...

Does the size of these backup arrays grow exponentially as the 'slice' increases its length (as they do in Go)?

Yes, if by that you mean that whenever more space is needed it doubles in size. (Not sure it is exactly that in OE, but it is double in phix.)
What happens in practice is that:
a) in the worst case some items may occupy nearly twice the theoretical minimum.
b) however freeing and de-fragmenting no longer needed space happens automatically and extremely efficiently,
c) and growing a list/table one element at a time is (obviously) far faster than copying the whole lot every time.
d) reference counting/memory sharing makes phix surprisingly memory thrifty, especially compared to many oo and dynamically typed languages.
e) almost always, you simply should not care much (except for deliberate memory hogging) about such details, it is in fact part of the core language philosophy that you should not need to.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu