Opened 9 years ago

Closed 9 years ago

#25093 closed New feature (fixed)

utils.datastructures.OrderedSet doesn't implement __len__

Reported by: Keryn Knight Owned by: Sambhav Satija
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: django@… 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

>>> x = set([1, 2])
>>> len(x)
2
>>> from django.utils.datastructures import OrderedSet
>>> y = OrderedSet([1, 2])
>>> len(y)
TypeError: object of type 'OrderedSet' has no len()

Given the implementation of __iter__, it seems like it would be plausible to re-use that:

>>> len([z for z in y])
2

Change History (5)

comment:1 by Tim Graham, 9 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:2 by Sambhav Satija, 9 years ago

Owner: changed from nobody to Sambhav Satija
Status: newassigned
Last edited 9 years ago by Sambhav Satija (previous) (diff)

comment:3 by Simon Charette, 9 years ago

Has patch: set
Needs tests: set
Patch needs improvement: set

comment:4 by Tim Graham, 9 years ago

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In f675afa:

Fixed #25093 -- Added utils.datastructures.OrderedSet.len()

Note: See TracTickets for help on using tickets.
Back to Top