#33724: Changing from list to set in `exclude` raises errors, and is not documented. -------------------------------------+------------------------------------- Reporter: אורי | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 4.1 (models, ORM) | Severity: Release blocker | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by אורי): Replying to [comment:6 Claude Paroz]: > Still I wonder if the performance gain is worth the loss of consistency. I wouldn't mind if exclude was defined to always be a set, but having to code defensively by expecting list or set is a loss in my point of view. I think logically it should be a set, because we don't need the same value twice and the order doesn't matter. But we should decide how to handle old code where it was a list. Maybe define it a set from now on, and write in the documentation that it must be a set. But I don't see any problem with including the following 4 lines every time we use `exclude`: {{{ if exclude is None: exclude = set() else: exclude = set(exclude) }}} By the way, since these 4 lines are repeated, maybe we can define a util function that takes `exclude` as an argument, and return a set. Either `set()` (if `exclude is None`) or `set(exclude)` otherwise. -- Ticket URL: <https://code.djangoproject.com/ticket/33724#comment:7> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070180df952f0b-10bb946d-b9ba-4944-8cb5-d746beb23020-000000%40eu-central-1.amazonses.com.