Mercurial > code > home > repos > light9
changeset 1177:eccb02a704cf
big speedup on graph.contains
Ignore-this: 53c970be29bac62467052ba11cedce53
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 15 Jun 2014 07:07:09 +0000 |
parents | c78a8f8a08ec |
children | a296d842d0da |
files | light9/rdfdb/rdflibpatch.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/rdfdb/rdflibpatch.py Sun Jun 15 06:50:04 2014 +0000 +++ b/light9/rdfdb/rdflibpatch.py Sun Jun 15 07:07:09 2014 +0000 @@ -53,7 +53,11 @@ c is just a URIRef. Workaround for https://github.com/RDFLib/rdflib/issues/398 """ - return (spoc[:3] + (Graph(identifier=spoc[3]),)) in graph.quads() + spoi = spoc[:3] + (Graph(identifier=spoc[3]),) + if spoi not in graph: + # this is a huge speedup, avoid many whole-graph scans + return False + return spoi in graph.quads() def graphFromQuads(q):