py2/py3: add str2unicode() utility function, that does nothing in Python 3.
Showing
-
Owner
maybe the lambda form causes some pylint warning, but in any case, I think both forms are OK.
I tried timeit and it seems equivalent from a performance point of view,
python3 -m timeit -s 'foo = lambda s: s' 'foo("")' ; python3 -m timeit -s 'def foo(s):' -s ' return s' 'foo("")'
Looking again at this patch, it would be a bit nicer to be consistent here, do you have a preference ? one point where function is a bit better, is that they have a meaningful
repr
<function str2bytes at 0x7f996ad848c0>
vs<function <lambda> at 0x7f996ad84848>
Please register or sign in to comment