Skip to content

Commit 4a99c44

Browse files
authored
Merge pull request #1765 from reyoung/feature/speed_up_int_converter
Speed up int scanner of data converter.
2 parents 3fffcd4 + c6f86cf commit 4a99c44

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

paddle/py_paddle/dataprovider_converter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,19 @@ def extend_cols(self, dat):
160160
class IndexScanner(IScanner):
161161
def __init__(self, input_type, pos):
162162
IScanner.__init__(self, input_type, pos)
163-
self.__ids__ = []
163+
self.__ids__ = None
164+
self.__idx__ = 0
165+
166+
def pre_scan(self, dat):
167+
self.__idx__ += 1
168+
169+
def finish_pre_scan(self, argument):
170+
self.__ids__ = [0] * self.__idx__
171+
self.__idx__ = 0
164172

165173
def scan(self, dat):
166-
self.__ids__.append(dat)
174+
self.__ids__[self.__idx__] = dat
175+
self.__idx__ += 1
167176

168177
def finish_scan(self, argument):
169178
ids = swig_paddle.IVector.create(self.__ids__, self.data_in_gpu)

0 commit comments

Comments
 (0)