Open chimezie opened 14 years ago
Hi Chimezie,
That makes a certain amount of sense. An alternate approach would be to cache the cardinality of different attributes (since most accesses will be repeats in common usage); have you considered that?
Feel free to fork or contribute patches!
Currently, any attribute access will triger a call to schema introspection to determine the cardinality of the set returned. This is not efficient for large schema graphs. Ideally, either schema introspection should be a global flag set by the user, or Thing.getattr should just return a generator over RDF objects and leave it up to the user to worry about the possibility of more than one RDF term being yielded
rdflib.util has a first utility method which is very useful when you only want the first item returned by a generator. However, using it with the attribute overrides of Sparta does not avoid the (possibly prohibitive) schema introspection. So, perhaps the use of a method like first renders the value of schema introspection moot (especially when you consider the cost of doing it)?