[Python] Find where f(x) changes in a list with bisection

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to implement, in Python, something similar to git bisect, but with basically a list of directories.

    I have a (long) list of version numbers like this: ['1.0', '1.14', '2.3', '3.1', '4']

    I have a function works() which takes a version number, and returns a value.

    [works(x) for x in my_list] would look like: ['foo', 'foo', 'foo', 'bar', 'bar'] ... but running works() is very expensive.

    I would like to do some kind of bisect which will find the change boundary.

    Continue reading...

Compartilhe esta Página