Avoid an unnecessary list creation in `DataChunk` (#64111)
authorSantiago Castro <sacastro@umich.edu>
Tue, 31 Aug 2021 02:17:21 +0000 (19:17 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 31 Aug 2021 02:25:42 +0000 (19:25 -0700)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/64111

Reviewed By: mruberry

Differential Revision: D30639383

Pulled By: ezyang

fbshipit-source-id: 96b243307413c99a67d55d862a71937e1ef210f4

torch/utils/data/dataset.py

index 7a069d6..609e1a1 100644 (file)
@@ -31,7 +31,7 @@ class DataChunk(list, Generic[T]):
         self.items = items
 
     def as_str(self, indent=''):
-        res = indent + "[" + ", ".join([str(i) for i in iter(self)]) + "]"
+        res = indent + "[" + ", ".join(str(i) for i in iter(self)) + "]"
         return res
 
     def __iter__(self) -> Iterator[T]: