Opened 4 years ago

Last modified 22 months ago

#32528 closed Cleanup/optimization

Replace django.utils.topological_sort with graphlib. — at Version 5

Reported by: Nick Pope Owned by: Nick Pope
Component: Utilities Version: dev
Severity: Normal Keywords: backport, graphlib, toposort, topological sort
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Nick Pope)

In Python 3.9 we have a new standard library module, graphlib, that includes a topological sort implementation.
Let's use this instead of our custom implementation in django.utils.topological_sort.

This will require a backport for Python 3.8, the minimum supported version for Django 4.0, but when support for Python 3.8 is removed we can simply drop the backport. When using Python 3.9+ we'll just use the module direct from the standard library.

Change History (5)

comment:1 by Nick Pope, 4 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 4 years ago

Triage Stage: UnreviewedSomeday/Maybe

Thanks for this report, however but I don't think we should backport this feature from Python or use it now. It would be hard to keep graphlib implementation and our backport in sync, it's not worth the maintenance burden. We can reconsider this ticket when Python 3.9 becomes the minimal Python supported by Django.

comment:3 by Nick Pope, 4 years ago

That's fine. Was really just putting this on the radar.

comment:4 by Nick Pope, 23 months ago

Triage Stage: Someday/MaybeAccepted

Whoop! The time has come. New PR.

comment:5 by Nick Pope, 23 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top