Forum OpenACS Development: Re: New Tcl API proc "package_exec_plsql" ...

Collapse
Posted by Andrew Piskorski on
ns_set preserves key order, right, thanks Tom, I forgot that one.

I think Jeff Davis said he once looked into the overheard due to using ns_sets for all the database stuff, and it was noticeable but not all that large. Maybe he said 10% or 20% or something like that, I really don't remember.

But in an unrelated project of my own I once made the mistake of using ns_sets with thousands of keys (or more) - this got quite slow. That's what originally made me pay attention to the fact that ns_set is often O(n) with set size, think about the fact that it's a legacy data structure, etc. (In that project, I didn't actually need any of the order preservation or multi-key properties of ns_set, so I just changed it to use Tcl arrays.)

My guess though is that any time you have a list of ns_sets, you probably don't have that many keys in each ns_set. And you probably don't have ns_set operations in an inner loop either like I did. So performance probably won't be a problem, you just get to deal with the possibly annoying programming aspects Don was talking about above.

ns_set seems fine to me for what it's intended for, just keep in mind that its O(n) performance means that ns_set is not suitable as a general purpose data structure.