This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mdk
Recipients larry, martin.panter, mdk, rhettinger, serhiy.storchaka, vstinner
Date 2016-11-26.11:44:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hi Serhiy,

> Julien, you can declare the hi parameter as
>    hi: Py_ssize_t(py_default="len(a)") = -1

Looks like a good idea, I was aware of its existance but did not took the time to read the doc about it, kind of learning step by stpe. But as you provided the syntax, I tested it, thanks for this! But it fails with a RuntimeError during python -m pydoc _bisect, I'm currently trying to understand why:

$ ./python -m pydoc _bisect 
Traceback (most recent call last):
  File "/home/mdk/cpython-git/Lib/", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/mdk/cpython-git/Lib/", line 85, in _run_code
    exec(code, run_globals)
  File "/home/mdk/cpython-git/Lib/", line 2663, in <module>
  File "/home/mdk/cpython-git/Lib/", line 2628, in cli
  File "/home/mdk/cpython-git/Lib/", line 1908, in help
    elif request: doc(request, 'Help on %s:', output=self._output)
  File "/home/mdk/cpython-git/Lib/", line 1645, in doc
    pager(render_doc(thing, title, forceload))
  File "/home/mdk/cpython-git/Lib/", line 1638, in render_doc
    return title % desc + '\n\n' + renderer.document(object, name)
  File "/home/mdk/cpython-git/Lib/", line 382, in document
    if inspect.ismodule(object): return self.docmodule(*args)
  File "/home/mdk/cpython-git/Lib/", line 1172, in docmodule
    contents.append(self.document(value, key, name))
  File "/home/mdk/cpython-git/Lib/", line 384, in document
    if inspect.isroutine(object): return self.docroutine(*args)
  File "/home/mdk/cpython-git/Lib/", line 1357, in docroutine
    signature = inspect.signature(object)
  File "/home/mdk/cpython-git/Lib/", line 2994, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/home/mdk/cpython-git/Lib/", line 2744, in from_callable
  File "/home/mdk/cpython-git/Lib/", line 2223, in _signature_from_callable
  File "/home/mdk/cpython-git/Lib/", line 2055, in _signature_from_builtin
    return _signature_fromstr(cls, func, s, skip_bound_arg)
  File "/home/mdk/cpython-git/Lib/", line 2003, in _signature_fromstr
    p(name, default)
  File "/home/mdk/cpython-git/Lib/", line 1985, in p
    default_node = RewriteSymbolics().visit(default_node)
  File "/home/mdk/cpython-git/Lib/", line 253, in visit
    return visitor(node)
  File "/home/mdk/cpython-git/Lib/", line 317, in generic_visit
    new_node = self.visit(old_value)
  File "/home/mdk/cpython-git/Lib/", line 253, in visit
    return visitor(node)
  File "/home/mdk/cpython-git/Lib/", line 1977, in visit_Name
    return wrap_value(
  File "/home/mdk/cpython-git/Lib/", line 1959, in wrap_value
    raise RuntimeError()

> > Curiously, this patch gives about a 10% to 15% speedup.  Any sense of how that improvement arises?
> This is rather a random difference. Try to run the bench several times.  With using Victor's perf module the difference is not significant.

If you search for "perf" in the history of this issue you'll see that I already tested with Victor's perf module and it yielded a consistent 18% improvement on bisect.bisect("abcdef", "c") on two different machines. Clearly with more than 5 items, it will start to fade, and with a lot of items, it's not significand, obviously as it's an optimization about the call and not the implementation. So Raymond's test with 100 items may still see a speedup.
Date User Action Args
2016-11-26 11:44:19mdksetrecipients: + mdk, rhettinger, vstinner, larry, martin.panter, serhiy.storchaka
2016-11-26 11:44:19mdksetmessageid: <>
2016-11-26 11:44:19mdklinkissue28754 messages
2016-11-26 11:44:18mdkcreate