It doesn't actually do a deep copy, and Python already has ways of doing a shallow copy (list(foo) and [*foo] for arbitrary iterables; foo[:] for indexable lists). Signed-off-by: Mantas Mikulėnas <grawity@xxxxxxxxx> --- lsusb.py.in | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lsusb.py.in b/lsusb.py.in index e54ee75..9ca734c 100644 --- a/lsusb.py.in +++ b/lsusb.py.in @@ -518,13 +518,6 @@ class UsbDevice: str += child.__str__() return str -def deepcopy(lst): - "Returns a deep copy from the list lst" - copy = [] - for item in lst: - copy.append(item) - return copy - def display_diff(lst1, lst2, fmtstr, args): "Compare lists (same length!) and display differences" for idx in range(0, len(lst1)): @@ -534,7 +527,7 @@ def display_diff(lst1, lst2, fmtstr, args): def fix_usbvend(): "Sort USB vendor list and (optionally) display diffs" if warnsort: - oldusbvend = deepcopy(usbvendors) + oldusbvend = usbvendors[:] usbvendors.sort() if warnsort: display_diff(usbvendors, oldusbvend, @@ -544,7 +537,7 @@ def fix_usbvend(): def fix_usbprod(): "Sort USB products list" if warnsort: - oldusbprod = deepcopy(usbproducts) + oldusbprod = usbproducts[:] usbproducts.sort() if warnsort: display_diff(usbproducts, oldusbprod, @@ -554,7 +547,7 @@ def fix_usbprod(): def fix_usbclass(): "Sort USB class list" if warnsort: - oldusbcls = deepcopy(usbclasses) + oldusbcls = usbclasses[:] usbclasses.sort() if warnsort: display_diff(usbclasses, oldusbcls, -- 2.21.0