Changing the graph.add() method parameters #1547
Replies: 7 comments
-
Candidate Method ImplementationsThis is the original
This next one is
This next one is
Finally,
|
Beta Was this translation helpful? Give feedback.
-
Testing methodology:Similar to how I benchmarked the new in-memory store. I generate 10,000 random unique triples. The runs are:
|
Beta Was this translation helpful? Give feedback.
-
Results:On Python 3.6:
On Python 3.7:
On Python 3.8:
|
Beta Was this translation helpful? Give feedback.
-
Interpretation:On Python 3.6: On Python 3.7: On Python 3.8: |
Beta Was this translation helpful? Give feedback.
-
Recommendation:After seeing these results, I see there is no reason we can't change the implementation of Remaining questions:
|
Beta Was this translation helpful? Give feedback.
-
Chiming in here briefly. When I started using rdflib now over 4 years ago I also balked at the fact that I had to work with whole triples, so I wrote a wrapper that would let me pass s, p, o in directly. In retrospect this was a mistake. There are indeed a number of cases where one might like to pass s, p, o individually, but in another number of cases you definitely do not want to do this because the code you are working with operates on whole triples. The end result of this change will be needless work pushed on to consumers of the rdflib api forced to add |
Beta Was this translation helpful? Give feedback.
-
I think this is an extremely valuable and useful insight. As advertised, “RDFLib is a Python library for working with RDF”. Its auxiliary role of offering a user-friendly interface to exploring/working with RDF directly is indeed valuable but it isn‘t RDFLib’s primary focus. Such a profound modification of a core library call seems a high price to pay for a what seems to be a minor degree of UI felicity. |
Beta Was this translation helpful? Give feedback.
-
It seems to be a fairly largely held annoyance that
graph.add()
takes atuple
object.I.e., it feels clunky do to:
g.add((subject, predicate, object))
with the double parentheses, when we should be able to do:g.add(subject, predicate, object)
RDFLib 6.0.0 coming soon has some breaking changes, so now would be the time to change this if we want to change it.
The problem is that even though we can have some rational breaking changes, making this change outright with no backwards compatibility would break literally every rdflib application, script, and workflow ever written.
So I've been doing some benchmarks of how to add a layer of backward compatibility without affecting performance too much.
These are my findings. (in the following comments)
Beta Was this translation helpful? Give feedback.
All reactions