Regression: Enum.enums returning list instead of tuple

Issue #3834 resolved
Lukas Siemon created an issue

The Enum.enums returning a list now instead of tuple.

Was this by design (I couldn't find it in the documentation)?

Imo it makes more sense to keep it immutable as tuple.

Comments (7)

  1. Mike Bayer repo owner

    it's dynamically generated now. Also I prefer using lists for variable-length sequences of homogeneous items. tuples are for fixed-length lists of heterogeneous items. I've been in a lot of religious wars over this one but Ned sums it up here: http://nedbatchelder.com/blog/201608/lists_vs_tuples.html

    The Cultural Difference is about how lists and tuples are actually used: lists are used where you have a homogenous sequence of unknown length; tuples are used where you know the number of elements in advance because the position of the element is semantically significant.

    In an enum, the position of the element is not semantically significant.

  2. Lukas Siemon reporter

    Sort of, yes. We have functions that assume input to be tuples.

    We are then passing the Enum.enums. So that failed after I upgraded to 1.1.2. I can just cast it, so this is not a big issue. Just thought it might be worth mentioning :)

  3. Lukas Siemon reporter

    My argumentation was: The list should never change after it's defined, so it should probably be a tuple. But your comment also makes sense. Personally I don't really care, just thought I'd mention it.

    Guess this can be closed then.

  4. Mike Bayer repo owner

    it's true the "lists are mutable" thing is what really prevents this list/tuple issue from being a simple thing in Python. There might be an immutablelist floating around in the codebase, i know i have one for dict.

  5. Log in to comment