Calculate Hand Value in a Blackjack Hand
This function doesn't have any really obvious inefficiencies, so I assume we're looking to shave off every possible clock cycle...

Sometimes it's faster to use Python's built-in aggregation functions than to use a for loop.  Here's how you could use sum and any:

def value(self) -&gt; int:
    value = sum(card.value for card in self.cards)
    if value &lt;= 11 and any(card.rank == "A" for card in self.cards):
        value += 10
    return value


Note the ordering of the and expression to make sure that the any iteration only happens if the value condition has already been met!

If you have flexibility over the representation of the cards, you might try making the rank an Enum with integer values.  I'd expect comparing two integer enums to be just a smidge faster than comparing two strings.