Cache type information on strings
During a selection operation, each value is matched against a regular expression and then casting might be performed, depending on the results. This commit caches the result of the match so that a value is not matched multiple times in its lifetime.
This commit is contained in:
parent
cd5c2845e1
commit
19cff69718
@ -35,10 +35,16 @@ class rstring (str):
|
||||
the following regexp:
|
||||
r'^[\+\-]{0,1}[0-9]+$'
|
||||
'''
|
||||
try:
|
||||
return self._isint
|
||||
except:
|
||||
pass
|
||||
|
||||
if re.match(r'^[\+\-]{0,1}[0-9]+$', self) == None:
|
||||
return False
|
||||
self._isint = False
|
||||
else:
|
||||
return True
|
||||
self._isint = True
|
||||
return self._isint
|
||||
|
||||
def isFloat(self):
|
||||
'''Returns true if the string represents a float number
|
||||
@ -46,10 +52,16 @@ class rstring (str):
|
||||
the following regexp:
|
||||
r'^[\+\-]{0,1}[0-9]+(\.([0-9])+)?$'
|
||||
'''
|
||||
try:
|
||||
return self._isfloat
|
||||
except:
|
||||
pass
|
||||
|
||||
if re.match(r'^[\+\-]{0,1}[0-9]+(\.([0-9])+)?$', self) == None:
|
||||
return False
|
||||
self._isfloat = False
|
||||
else:
|
||||
return True
|
||||
self._isfloat = True
|
||||
return self._isfloat
|
||||
|
||||
def isDate(self):
|
||||
'''Returns true if the string represents a date,
|
||||
|
Loading…
x
Reference in New Issue
Block a user