Skip to content

Commit

Permalink
Merge pull request #3716 from ehsantn/unicode_iadd
Browse files Browse the repository at this point in the history
Support inplace concat of strings
  • Loading branch information
sklam committed Jan 30, 2019
2 parents 5277c63 + 5c2a841 commit e475b97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions numba/tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def getitem_usecase(x, i):
def concat_usecase(x, y):
return x + y

def inplace_concat_usecase(x, y):
x += y
return x

def in_usecase(x, y):
return x in y
Expand Down Expand Up @@ -291,6 +294,15 @@ def test_concat(self, flags=no_pyobj_flags):
cfunc(a, b),
"'%s' + '%s'?" % (a, b))

def test_inplace_concat(self, flags=no_pyobj_flags):
pyfunc = inplace_concat_usecase
cfunc = njit(pyfunc)
for a in UNICODE_EXAMPLES:
for b in UNICODE_EXAMPLES[::-1]:
self.assertEqual(pyfunc(a, b),
cfunc(a, b),
"'%s' + '%s'?" % (a, b))

def test_pointless_slice(self, flags=no_pyobj_flags):
def pyfunc(a):
return a[:]
Expand Down
1 change: 1 addition & 0 deletions numba/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ def getitem_slice(s, idx):


@overload(operator.add)
@overload(operator.iadd)
def unicode_concat(a, b):
if isinstance(a, types.UnicodeType) and isinstance(b, types.UnicodeType):
def concat_impl(a, b):
Expand Down

0 comments on commit e475b97

Please sign in to comment.