for this specific test casethe dictionary-based set implementation (fastestis roughly three times faster than the simple list-based set (setin factthis threefold speedup is probably sufficient python dictionaries are already optimized hashtables that you might be hard-pressed to improve on unless there is evidence that dictionary-based sets are still too slowour work here is probably done by comparisonresults for python in the prior edition of this book showed fastest to be six times faster than set in all cases either iteration operations sped upor dictionary operations slowed down in in the even older python and second editionthe relative results were the same as they are today in python in any eventthis well underscores the fact that you must test performance on your machine and your python--today' python performance observation may easily be tomorrow' historic anecdote adding relational algebra to sets (externalif you are interested in studying additional set-like operations coded in pythonsee the following files in this book' examples distributionpp \dstruct\basic\rset py rset implementation pp \dstruct\basic\reltest py test script for rsetits expected output is in reltest results txt the rset subclass defined in rset py adds basic relational algebra operations for sets of dictionaries it assumes the items in sets are mappings (rows)with one entry per column (fieldrset inherits all the original set operations (iterationintersectionunionand operatorsuniqueness filteringand so on)and adds new operations as methodsselect return set of nodes that have field equal to given value bagof collect set nodes that satisfy an expression string find select tuples according to comparisonfieldand value match find nodes in two sets with the same values for common fields product compute cartesian productconcatenate tuples from two sets join combine tuples from two sets that have the same value for field data structures