Mercurial > code > home > repos > light9
changeset 1424:4098f5f244ea
cache Namespace term creation.
Ignore-this: 21eb17fc1fbf1a229029f6981d79458d
author | drewp@bigasterisk.com |
---|---|
date | Sat, 11 Jun 2016 04:29:38 +0000 |
parents | 6cc84beb84a4 |
children | 8796803a1b45 |
files | light9/namespaces.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/namespaces.py Sat Jun 11 04:29:12 2016 +0000 +++ b/light9/namespaces.py Sat Jun 11 04:29:38 2016 +0000 @@ -1,6 +1,18 @@ from rdflib import Namespace, RDF, RDFS -L9 = Namespace("http://light9.bigasterisk.com/") + +# Namespace was showing up in profiles +class FastNs(object): + def __init__(self, base): + self.ns = Namespace(base) + self.cache = {} + def __getitem__(self, term): + if term not in self.cache: + self.cache[term] = self.ns[term] + return self.cache[term] + __getattr__ = __getitem__ + +L9 = FastNs("http://light9.bigasterisk.com/") MUS = Namespace("http://light9.bigasterisk.com/music/") XSD = Namespace("http://www.w3.org/2001/XMLSchema#") DCTERMS = Namespace("http://purl.org/dc/terms/")