I've been trying to determine the best way of testing whether there is a selection set present on a layer using ArcPy. As many of you will be aware, the Get Count (Data Management) method returns a count of the total number features selected in a layer, or failing that (when there is no selection present) the total number of features in that layer. So initially, the method I used to check for a selection set was to compare the number returned by Get Count with the number returned by a Get Count done on the layer's underlying feature class accessed via the Describe CatalogPath property (ignoring the issue where all features are selected).
This method worked fine until I started testing this with layers that had been created as subsets of features from an actual feature class using the 'Create layer from selected features' (ArcMap>Table of Contents>Right-click>Selection>Create layer from selected features). In this case the Get Count accessed via the Describe CatalogPath property will always be different to that returned when done on the layer.
So then I stumbled on the lesser known FIDSet Describe property, and thought great problem solved. However, this was not the case: the FIDSet property works as you'd expect it should for layers that are based directly on an underlying feature class i.e. it returns a list of OIDs for selected features, or an empty list if none are selected, BUT, it works differently if your layer was created as a selection from another layer. In the latter case, if no features are selected it returns a list of OIDs for all of the features in the layer (like Get Count).
My current workaround for this issue, works for all cases (tested so far!) but adds an unwanted overhead to the script tools that use it. My method to test whether or not a selection set is present is to temporarily switch the selection set and then check if the count on this is zero. If it is zero then there's no selection set and conversely if it's not zero then there is. This works fine, but when this is run on large data sets this switching selection back and forth can be quite slow. So my question is, can anyone suggest a better performing method that will work for all cases?
p.s. the FIDSet issue is already listed on ESRI Ideas.