numexpr
numexpr copied to clipboard
NE3: Byte and Unicode string support
NE2 had very limited support for ascii-encoded strings (with the contains function and comparisons). Likely additional function could be added to NE3 if someone who does string processing could be found to implement them.
The main question is how to interact with the Python Unicode object, and how to get the byte-depth used (i.e. UTF-8 versus UTF-16 versus UTF-32).
I guess you already have one, but in case you need a small test for python3:
import numexpr as ne
data_text = {'a': 'b'}
data_byte = {'a': b'b'}
condition = "(a=='a')"
try:
r_text = ne.evaluate(condition, data_text)
except Exception as error:
print('Exception when text', error)
r_byte = ne.evaluate(condition, data_byte)
print('Byte version', r_byte)
This code prints:
Exception when text unknown type str32
Byte version False
It fails when trying using python3's string but it works for byte. I also notice that we don't need the byte version for the condition (paramter ex).
Hi is this planned to be released? Very intested in the unicode support
Message to comment on stale issues. If none provided, will not mark issues stale