Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

Michele, Alessandro, thank you both for your work! And thank you Cheryl for 
managing this ticket.

I like mangrisano's design where the target time is passed as an argument to 
the ``autorange`` method, although I prefer the name "target_time". (But I'm 
open to alternatives.)

So I think a good approach might be a hybrid between mangrisano's design, and 
the design by Alessandro:

1. the constructor takes the target time and records it as an attribute;

def __init__(self, ..., target_time=default_target_time):
    self.target_time = target_time


2. when the ``timeit`` method is used, if number=0 the target time is taken 
from self.target_time and passed to ``autorange``;

- if the ``autorange`` method is called directly, the caller can override the 
target time by passing it as argument; otherwise the default value is looked up 
from the instance attribute.

So something like

def autorange(self, callback=None, target_time=None):
    if target_time is None:
        target_time = self.target_time
    ...


Please suggest alternatives or point out anything I may have missed, and thank 
you all again!

(I'm now going to be away from the keyboard for at least the next 18 hours so 
if I don't reply quickly, that's why.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36461>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to