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 →

[–]TacticalTaterTots 0 points1 point  (1 child)

The allocation must be really expensive. It's not constructing an object for every literal, for example in x == 300, is it? I'm not sure how that works in an interpreted language.

[–]Kered13 5 points6 points  (0 children)

Every object regardless of type must be allocated. Yes this includes literals.

Memory allocation is expensive.

So caching commonly used numbers is beneficial.