I've been reading about the tradeoffs between different iteration methods, and the consensus seems to be that dolist, dotimes, and cl-loop are more efficient than mapc and seq-do, because the former methods macro-expand (in almost all cases) to a while loop, while the latter require a lambda, which are generally slower and harder to debug. I see what you're saying that allocating a list of keys just to iterate once over a hash table would be wasteful. And I suppose it also wouldn't make sense to have a built-in just for iterating over hash-tables. Shankar Rao On Thu, Nov 28, 2024 at 6:31 PM Mattias Engdegård < mattias.engdegard@gmail.com> wrote: > 28 nov. 2024 kl. 12.53 skrev Shankar Rao : > > > I noticed that the functions hash-table-keys and hash-table-values are > just wrappers around maphash. This means that there is no way to iterate > over a hash-table without using a lambda. > > > > Would it be useful or worthwhile to implement these directly in C? I > don't know much about low-level Emacs development, but having these as > built-ins could make iteration of a hash-table a little faster and easier > to debug. > > It's unlikely that it would be faster to make a list just for the purpose > of a single iteration; the allocation costs alone would be too high. Other > ways of iterating through hash-tables have been tried with mostly > disappointing results, although there might be some value in avoiding use > of the C stack in some cases. > > If you tell us what you are trying to accomplish, it would be easier for > us to help you. > >