p-hofmann / SMBEdit

StarMade Blueprint Editor
5 stars 1 forks source link

SmdBlock - memory usage #5

Closed p-hofmann closed 7 years ago

p-hofmann commented 7 years ago

A SmdBlock object is made for every block. Storing the integer representing a block and using a SmdBlock only when needed would save a lot of space.

Septaris commented 7 years ago

We can do it using singleton metaclass and class manager. The idea is to return only a new instance for new blocks (new IDs) and return the existing instance if the ID is already used (like the logger class in the logging module).

An example of a working implementation (based on my previous work, compatible with python 2 and 3) : example.zip

p-hofmann commented 7 years ago

I like that solution! I will play around with it when I find the time.