Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-10-11 09:17:56


From: "Gary Powell" <Gary.Powell_at_[hidden]>

> Hi,
> I have another observation, and that is if you stored the array
"enablers"
> sorted by key you could do a binary search instead of a linear one in
> "enable_special_methods" and "enable_named_method". since the array
enablers
> is relatively small it won't be a big time savings, but since you have
full
> control of it, you might as well do the easy optimization here. (I would
> also put a note next to the array to alert future additions to insert them
> in sorted order.)

Well, it's a trade-off. As you say, there's the maintenance issue. Also, the
call to lower_bound() would doubtless generate more code. And then there's
the lack of certainty that it would make any measurable difference in speed
where it matters, or even that it would be any faster at all. Remember, this
function is called:

a. At Python module initialization time, when the cost will probably be
masked by the cost of loading the code from disk.
b. When the user defines new member functions from Python. In most cases if
the user is executing Python code, fine-grained speed details like this
don't matter.

I am open to being influenced on this, but am inclined to leave it as is.

-dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk