此问题来自answer我提供给另一个question (针对特定目的优化二进制搜索)
示例是bisect
库。
当我使用默认bisect
运行from bisect import *
库时,它比>3.5
粘贴到ipython
中的# define array
a = [0, 0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 11, 15, 24]
# Copying the raw code from the source from bisect into ipython
# using ipython's magic %paste command
%paste
...
%timeit bisect_left(a, 1), bisect_right(a, 1)
1000000 loops, best of 3: 1.77 µs per loop
# now importing and using the python default functions...
from bisect import bisect_left, bisect_right
%timeit bisect_left(a, 1), bisect_right(a, 1)
1000000 loops, best of 3: 504 ns per loop
快... {/ 1}} p>
Button button = (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//set the variable.
}
});
问题