# HG changeset patch # User drewp@bigasterisk.com # Date 1465619378 0 # Node ID 4098f5f244eada14b970e60487b7cf809d9a5528 # Parent 6cc84beb84a49d332b1efe1e40f464e539b29ce0 cache Namespace term creation. Ignore-this: 21eb17fc1fbf1a229029f6981d79458d diff -r 6cc84beb84a4 -r 4098f5f244ea light9/namespaces.py --- 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/")