CardFactory.__iter__ memory efficiency is not optimal.

Issue #1 resolved
Enrico Franchi
created an issue

Creates lots of new cards. Probably we want create_cards to memoize created cards.

Comments (2)

  1. Giacomo Alzetta repo owner

    I think the easiest way of memoizing would be adding a dictionary "_built_cards" and use the setdefault method of dictionaries.(as i did in the attached file). an other approach would be to use a class-decorator to holde the dictionary...

  2. Enrico Franchi reporter

    The one you did is simpler. If we need memoizing more things, we'll move memoizing to decorators and such. I added a test to prove the current implementation is not "correct" with respect to what we decided. As far as I'm concerned, it's solved. Since you have a (likely) working patch, I assign this to you.

  3. Log in to comment