odd behavoiur seen

Chris Hinsley chris.hinsley at gmail.com
Mon Jul 22 20:42:47 CEST 2013


On 2013-07-22 18:36:41 +0000, Chris Hinsley said:

> Folks, I have this decorator:
> 
> def memoize(maxsize):
>     def _memoize(func):
>         lru_cache = {}
>         lru_list = []

Other clues, I use it on a recursive function:

@memoize(64)
def next_move(board, colour, alpha, beta, ply):
    if ply <= 0:
        return evaluate(board) * colour
    for new_board in all_moves(board[:], colour):
        score = -next_move(new_board, -colour, -beta, -alpha, ply - 1)
        if score >= beta:
            return score
        if score > alpha:
            alpha = score
    return alpha

And I notice I don't get the strange problem on a non-recursive 
function ! Or at least I don't seam to.

Chris




More information about the Python-list mailing list