Are hooks indexed when Drupal loads? Wondering how Drupal manages hooks outside of the core in modules. Seems like parsing the code in modules would add a lot of overhead, and that it's more likely that the code is doing something else to manage the calls; for example, indexing or compiling the code when Drupal boots for the first time.

If there's a difference between how 6 and 7 handles this, please explain how each handles it, or clearly state which version you've explained.
I can't speak for Drupal 6 (haven't used it in a while), but in Drupal 7 the standard method used to invoke a hook is something like the following:

$modules = module_implements('some_hook');
foreach ($modules as $module) {
  // Call the hook
}


module_implements() caches the hook implementations, and as such the index is only rebuilt when the caches are cleared (or more specifically, the bootstrap cache).

As for parsing the code in modules, this falls outside of Drupal's jurisdiction; PHP will parse all of the code in any included file. Since hooks must reside in a .module file (or at least a file that's explicitly included from a module file), and all enabled module files are included on each page request, the whole file will be parsed every time.