Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
049ade29
Kaydet (Commit)
049ade29
authored
Şub 28, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Complete the previous effort to factor out constant expressions
and improve the speed of the if/elif/else blocks.
üst
9533e340
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
12 deletions
+34
-12
sre_compile.py
Lib/sre_compile.py
+15
-4
sre_parse.py
Lib/sre_parse.py
+19
-8
No files found.
Lib/sre_compile.py
Dosyayı görüntüle @
049ade29
...
...
@@ -24,14 +24,25 @@ else:
def
_identityfunction
(
x
):
return
x
def
set
(
seq
):
s
=
{}
for
elem
in
seq
:
s
[
elem
]
=
1
return
s
_LITERAL_CODES
=
set
([
LITERAL
,
NOT_LITERAL
])
_REPEATING_CODES
=
set
([
REPEAT
,
MIN_REPEAT
,
MAX_REPEAT
])
_SUCCESS_CODES
=
set
([
SUCCESS
,
FAILURE
])
_ASSERT_CODES
=
set
([
ASSERT
,
ASSERT_NOT
])
def
_compile
(
code
,
pattern
,
flags
):
# internal: compile a (sub)pattern
emit
=
code
.
append
_len
=
len
LITERAL_CODES
=
{
LITERAL
:
1
,
NOT_LITERAL
:
1
}
REPEATING_CODES
=
{
REPEAT
:
1
,
MIN_REPEAT
:
1
,
MAX_REPEAT
:
1
}
SUCCESS_CODES
=
{
SUCCESS
:
1
,
FAILURE
:
1
}
ASSERT_CODES
=
{
ASSERT
:
1
,
ASSERT_NOT
:
1
}
LITERAL_CODES
=
_LITERAL_CODES
REPEATING_CODES
=
_REPEATING_CODES
SUCCESS_CODES
=
_SUCCESS_CODES
ASSERT_CODES
=
_ASSERT_CODES
for
op
,
av
in
pattern
:
if
op
in
LITERAL_CODES
:
if
flags
&
SRE_FLAG_IGNORECASE
:
...
...
Lib/sre_parse.py
Dosyayı görüntüle @
049ade29
...
...
@@ -16,15 +16,21 @@ import sys
from
sre_constants
import
*
def
set
(
seq
):
s
=
{}
for
elem
in
seq
:
s
[
elem
]
=
1
return
s
SPECIAL_CHARS
=
".
\\
[{()*+?^$|"
REPEAT_CHARS
=
"*+?{"
DIGITS
=
tuple
(
"0123456789"
)
DIGITS
=
set
(
"0123456789"
)
OCTDIGITS
=
tuple
(
"01234567"
)
HEXDIGITS
=
tuple
(
"0123456789abcdefABCDEF"
)
OCTDIGITS
=
set
(
"01234567"
)
HEXDIGITS
=
set
(
"0123456789abcdefABCDEF"
)
WHITESPACE
=
tuple
(
"
\t\n\r\v\f
"
)
WHITESPACE
=
set
(
"
\t\n\r\v\f
"
)
ESCAPES
=
{
r"\a"
:
(
LITERAL
,
ord
(
"
\a
"
)),
...
...
@@ -371,6 +377,11 @@ def _parse_sub_cond(source, state, condgroup):
subpattern
.
append
((
GROUPREF_EXISTS
,
(
condgroup
,
item_yes
,
item_no
)))
return
subpattern
_PATTERNENDERS
=
set
(
"|)"
)
_ASSERTCHARS
=
set
(
"=!<"
)
_LOOKBEHINDASSERTCHARS
=
set
(
"=!"
)
_REPEATCODES
=
set
([
MIN_REPEAT
,
MAX_REPEAT
])
def
_parse
(
source
,
state
):
# parse a simple pattern
subpattern
=
SubPattern
(
state
)
...
...
@@ -380,10 +391,10 @@ def _parse(source, state):
sourceget
=
source
.
get
sourcematch
=
source
.
match
_len
=
len
PATTERNENDERS
=
(
"|"
,
")"
)
ASSERTCHARS
=
(
"="
,
"!"
,
"<"
)
LOOKBEHINDASSERTCHARS
=
(
"="
,
"!"
)
REPEATCODES
=
(
MIN_REPEAT
,
MAX_REPEAT
)
PATTERNENDERS
=
_PATTERNENDERS
ASSERTCHARS
=
_ASSERTCHARS
LOOKBEHINDASSERTCHARS
=
_LOOKBEHINDASSERTCHARS
REPEATCODES
=
_REPEATCODES
while
1
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment