Browse Source

Merge pull request #114 from jayvdb/tokenizer_loading

Lazy loading of pure Python tokenizer
tags/v0.4.1
Ben Kurtovic 9 years ago
parent
commit
dcca42abb0
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      mwparserfromhell/parser/__init__.py

+ 2
- 1
mwparserfromhell/parser/__init__.py View File

@@ -40,11 +40,11 @@ class ParserError(Exception):




from .builder import Builder from .builder import Builder
from .tokenizer import Tokenizer
try: try:
from ._tokenizer import CTokenizer from ._tokenizer import CTokenizer
use_c = True use_c = True
except ImportError: except ImportError:
from .tokenizer import Tokenizer
CTokenizer = None CTokenizer = None
use_c = False use_c = False


@@ -70,6 +70,7 @@ class Parser(object):
if use_c and CTokenizer: if use_c and CTokenizer:
self._tokenizer = CTokenizer() self._tokenizer = CTokenizer()
else: else:
from .tokenizer import Tokenizer
self._tokenizer = Tokenizer() self._tokenizer = Tokenizer()
self._builder = Builder() self._builder = Builder()




Loading…
Cancel
Save