Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  lazy_re.py   Sprache: Python

 
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

'''In GRIT, we used to compile a lot of regular expressions at parse
time.  Since many of them never get used, we use lazy_re to compile
them on demand the first time they are used, thus speeding up startup
time in some cases.
'''

from __future__ import print_function

import re


class LazyRegexObject(object):
  '''This object creates a RegexObject with the arguments passed in
  its constructor, the first time any attribute except the several on
  the class itself is accessed.  This accomplishes lazy compilation of
  the regular expression while maintaining a nearly-identical
  interface.
  '''

  def __init__(self, *args, **kwargs):
    self._stash_args = args
    self._stash_kwargs = kwargs
    self._lazy_re = None

  def _LazyInit(self):
    if not self._lazy_re:
      self._lazy_re = re.compile(*self._stash_args, **self._stash_kwargs)

  def __getattribute__(self, name):
    if name in ('_LazyInit''_lazy_re''_stash_args''_stash_kwargs'):
      return object.__getattribute__(self, name)
    else:
      self._LazyInit()
      return getattr(self._lazy_re, name)


def compile(*args, **kwargs):
  '''Creates a LazyRegexObject that, when invoked on, will compile a
  re.RegexObject (via re.compile) with the same arguments passed to
  this function, and delegate almost all of its methods to it.
  '''
  return LazyRegexObject(*args, **kwargs)

Messung V0.5
C=92 H=98 G=94

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge