Opened 10 years ago

Closed 10 years ago

#23796 closed Cleanup/optimization (fixed)

Reduced reduce() usage

Reported by: Brad Walker Owned by: nobody
Component: Uncategorized Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Change History (5)

comment:1 by Brad Walker, 10 years ago

Easy pickings: set
Version: 1.7master

comment:2 by Josh Smeaton, 10 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Tim Graham <timograham@…>, 10 years ago

In cfa26f29bdd9b0f82211e6f5ff7f4cd63bd66150:

Reduced reduce() usage; refs #23796.

django.core.exceptions.ValidationError.messages() and
django.db.backends.schema.BaseDatabaseSchemaEditor._alter_field():
Replaced reduce(operator.add, ...) w/uncoupled, explicit sum()

comment:4 by Tim Graham <timograham@…>, 10 years ago

In 54d3dcbc51819ea0e36bb4dbe7de1a1e33f62c4d:

Removed reduce() usage in makemigrations; refs #23796.

A lambda all_items_equal() replaced a reduce() that was broken for potential
3+-way merges. A reduce(operator.eq, ...) accumulates bools and can't
generically check equality of all items in a sequence:

bool(reduce(operator.eq, [('migrations', '0001_initial')] * 3))

False

The code now counts the number of common ancestors to calculate slice offsets
for the branches. Each branch shares the same number of common ancestors.

The common_ancestor for loop statement had incomplete branch coverage.

comment:5 by Tim Graham, 10 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top