[python-ldap] Performance improvement for schema.tokenizer.split_tokens

Petr Viktorin pviktori at redhat.com
Tue Feb 28 09:58:45 EST 2017


On 02/22/2017 10:24 PM, Michael Ströder wrote:
> Christian Heimes wrote:
>> On 2017-02-18 18:39, Michael Ströder wrote:
>>> Michael Ströder wrote:
>>>> I see you're coming close to my own (non-published) attempts of working around some
>>>> schema bugs. But is it still that much faster then? ;-)
>>>
>>> Overall schema parsing done in ldap.schema.SubSchema.__init__() is twice as fast with
>>> your recent implementation. That's great!
>>
>> here is a patch against latest CVS head including some additional test
>> cases.
>
> I've slightly modified your patch for backward compability to older Python versions.
>
>> I changed the regular expression to handle backslash quoting of
>> single quotes within single quotes. A co-worker also noticed that my
>> implementation did not check for closing parenthesis before opening
>> parenthesis. I added a check for the special case, too (thx Standa).
>
> Thanks. This revealed an error in my Æ-DIR suppl. schema for web2ldap.
>
> Maybe I did something wrong but one bad case does not raise ValueError as expected:
>
> $ PYTHONPATH=Lib python Tests/t_ldap_schema_tokenizer.py
> .Fxx.
> ======================================================================
> FAIL: test_broken (__main__.TestSplitTokens)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "Tests/t_ldap_schema_tokenizer.py", line 115, in test_broken
>     self._run_failure_tests(TESTCASES_BROKEN)
>   File "Tests/t_ldap_schema_tokenizer.py", line 84, in _run_failure_tests
>     should_have_failed,
> AssertionError: 1 value(s) should have raised ValueError: ['( BLUB )) DA (']
>
> ----------------------------------------------------------------------
> Ran 5 tests in 0.001s
>
> FAILED (failures=1, expected failures=2)
>
> Ciao, Michael.

It's actually two cases, apply the attached patch to see the other one.



-- 
Petr Viktorin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testfix.patch
Type: text/x-patch
Size: 570 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170228/1fb77834/attachment.bin>


More information about the python-ldap mailing list