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
> 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
> is relatively small it won't be a big time savings, but since you have
> 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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at