mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
We use the python function again with the modifications we need.
I ran it with:
python3 -m timeit -n 10000 -s 'from jedi.common import splitlines; x = open("test_regression.py").read()'
The speed differences are quite remarkable, it's ~3 times faster:
10000 loops, best of 3: 52.1 usec per loop
vs. the old:
10000 loops, best of 3: 148 usec per loop
We might need to speedup splitlines with as well. It's probably
also a factor 2-3 slower than it should be.
18 lines
647 B
Python
18 lines
647 B
Python
from jedi.common import splitlines
|
|
|
|
|
|
def test_splitlines_no_keepends():
|
|
assert splitlines('asd\r\n') == ['asd', '']
|
|
assert splitlines('asd\r\n\f') == ['asd', '\f']
|
|
assert splitlines('\fasd\r\n') == ['\fasd', '']
|
|
assert splitlines('') == ['']
|
|
assert splitlines('\n') == ['', '']
|
|
|
|
|
|
def test_splitlines_keepends():
|
|
assert splitlines('asd\r\n', keepends=True) == ['asd\r\n', '']
|
|
assert splitlines('asd\r\n\f', keepends=True) == ['asd\r\n', '\f']
|
|
assert splitlines('\fasd\r\n', keepends=True) == ['\fasd\r\n', '']
|
|
assert splitlines('', keepends=True) == ['']
|
|
assert splitlines('\n', keepends=True) == ['\n', '']
|