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
6d336a02
Kaydet (Commit)
6d336a02
authored
May 09, 2017
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
May 09, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30285: Optimize case-insensitive matching and searching (#1482)
of regular expressions.
üst
f93234bb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
1 deletion
+113
-1
3.7.rst
Doc/whatsnew/3.7.rst
+4
-0
sre_compile.py
Lib/sre_compile.py
+0
-0
test_re.py
Lib/test/test_re.py
+9
-0
NEWS
Misc/NEWS
+3
-0
_sre.c
Modules/_sre.c
+34
-0
_sre.c.h
Modules/clinic/_sre.c.h
+63
-1
No files found.
Doc/whatsnew/3.7.rst
Dosyayı görüntüle @
6d336a02
...
@@ -208,6 +208,10 @@ Optimizations
...
@@ -208,6 +208,10 @@ Optimizations
using the :func:`os.scandir` function.
using the :func:`os.scandir` function.
(Contributed by Serhiy Storchaka in :issue:`25996`.)
(Contributed by Serhiy Storchaka in :issue:`25996`.)
* Optimized case-insensitive matching and searching of :mod:`regular
expressions <re>`. Searching some patterns can now be up to 20 times faster.
(Contributed by Serhiy Storchaka in :issue:`30285`.)
Build and C API Changes
Build and C API Changes
=======================
=======================
...
...
Lib/sre_compile.py
Dosyayı görüntüle @
6d336a02
This diff is collapsed.
Click to expand it.
Lib/test/test_re.py
Dosyayı görüntüle @
6d336a02
...
@@ -891,15 +891,24 @@ class ReTests(unittest.TestCase):
...
@@ -891,15 +891,24 @@ class ReTests(unittest.TestCase):
lo
=
ord
(
c
.
lower
())
lo
=
ord
(
c
.
lower
())
self
.
assertEqual
(
_sre
.
ascii_tolower
(
i
),
lo
)
self
.
assertEqual
(
_sre
.
ascii_tolower
(
i
),
lo
)
self
.
assertEqual
(
_sre
.
unicode_tolower
(
i
),
lo
)
self
.
assertEqual
(
_sre
.
unicode_tolower
(
i
),
lo
)
iscased
=
c
in
string
.
ascii_letters
self
.
assertEqual
(
_sre
.
ascii_iscased
(
i
),
iscased
)
self
.
assertEqual
(
_sre
.
unicode_iscased
(
i
),
iscased
)
for
i
in
list
(
range
(
128
,
0x1000
))
+
[
0x10400
,
0x10428
]:
for
i
in
list
(
range
(
128
,
0x1000
))
+
[
0x10400
,
0x10428
]:
c
=
chr
(
i
)
c
=
chr
(
i
)
self
.
assertEqual
(
_sre
.
ascii_tolower
(
i
),
i
)
self
.
assertEqual
(
_sre
.
ascii_tolower
(
i
),
i
)
if
i
!=
0x0130
:
if
i
!=
0x0130
:
self
.
assertEqual
(
_sre
.
unicode_tolower
(
i
),
ord
(
c
.
lower
()))
self
.
assertEqual
(
_sre
.
unicode_tolower
(
i
),
ord
(
c
.
lower
()))
iscased
=
c
!=
c
.
lower
()
or
c
!=
c
.
upper
()
self
.
assertFalse
(
_sre
.
ascii_iscased
(
i
))
self
.
assertEqual
(
_sre
.
unicode_iscased
(
i
),
c
!=
c
.
lower
()
or
c
!=
c
.
upper
())
self
.
assertEqual
(
_sre
.
ascii_tolower
(
0x0130
),
0x0130
)
self
.
assertEqual
(
_sre
.
ascii_tolower
(
0x0130
),
0x0130
)
self
.
assertEqual
(
_sre
.
unicode_tolower
(
0x0130
),
ord
(
'i'
))
self
.
assertEqual
(
_sre
.
unicode_tolower
(
0x0130
),
ord
(
'i'
))
self
.
assertFalse
(
_sre
.
ascii_iscased
(
0x0130
))
self
.
assertTrue
(
_sre
.
unicode_iscased
(
0x0130
))
def
test_not_literal
(
self
):
def
test_not_literal
(
self
):
self
.
assertEqual
(
re
.
search
(
r"\s([^a])"
,
" b"
)
.
group
(
1
),
"b"
)
self
.
assertEqual
(
re
.
search
(
r"\s([^a])"
,
" b"
)
.
group
(
1
),
"b"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
6d336a02
...
@@ -320,6 +320,9 @@ Extension Modules
...
@@ -320,6 +320,9 @@ Extension Modules
Library
Library
-------
-------
- bpo-30285: Optimized case-insensitive matching and searching of regular
expressions.
- bpo-29990: Fix range checking in GB18030 decoder. Original patch by Ma Lin.
- bpo-29990: Fix range checking in GB18030 decoder. Original patch by Ma Lin.
- bpo-29979: rewrite cgi.parse_multipart, reusing the FieldStorage class and
- bpo-29979: rewrite cgi.parse_multipart, reusing the FieldStorage class and
...
...
Modules/_sre.c
Dosyayı görüntüle @
6d336a02
...
@@ -273,6 +273,38 @@ _sre_getcodesize_impl(PyObject *module)
...
@@ -273,6 +273,38 @@ _sre_getcodesize_impl(PyObject *module)
return
sizeof
(
SRE_CODE
);
return
sizeof
(
SRE_CODE
);
}
}
/*[clinic input]
_sre.ascii_iscased -> bool
character: int
/
[clinic start generated code]*/
static
int
_sre_ascii_iscased_impl
(
PyObject
*
module
,
int
character
)
/*[clinic end generated code: output=4f454b630fbd19a2 input=9f0bd952812c7ed3]*/
{
unsigned
int
ch
=
(
unsigned
int
)
character
;
return
ch
!=
sre_lower
(
ch
)
||
ch
!=
sre_upper
(
ch
);
}
/*[clinic input]
_sre.unicode_iscased -> bool
character: int
/
[clinic start generated code]*/
static
int
_sre_unicode_iscased_impl
(
PyObject
*
module
,
int
character
)
/*[clinic end generated code: output=9c5ddee0dc2bc258 input=51e42c3b8dddb78e]*/
{
unsigned
int
ch
=
(
unsigned
int
)
character
;
return
ch
!=
sre_lower_unicode
(
ch
)
||
ch
!=
sre_upper_unicode
(
ch
);
}
/*[clinic input]
/*[clinic input]
_sre.ascii_tolower -> int
_sre.ascii_tolower -> int
...
@@ -2750,6 +2782,8 @@ static PyTypeObject Scanner_Type = {
...
@@ -2750,6 +2782,8 @@ static PyTypeObject Scanner_Type = {
static
PyMethodDef
_functions
[]
=
{
static
PyMethodDef
_functions
[]
=
{
_SRE_COMPILE_METHODDEF
_SRE_COMPILE_METHODDEF
_SRE_GETCODESIZE_METHODDEF
_SRE_GETCODESIZE_METHODDEF
_SRE_ASCII_ISCASED_METHODDEF
_SRE_UNICODE_ISCASED_METHODDEF
_SRE_ASCII_TOLOWER_METHODDEF
_SRE_ASCII_TOLOWER_METHODDEF
_SRE_UNICODE_TOLOWER_METHODDEF
_SRE_UNICODE_TOLOWER_METHODDEF
{
NULL
,
NULL
}
{
NULL
,
NULL
}
...
...
Modules/clinic/_sre.c.h
Dosyayı görüntüle @
6d336a02
...
@@ -29,6 +29,68 @@ exit:
...
@@ -29,6 +29,68 @@ exit:
return
return_value
;
return
return_value
;
}
}
PyDoc_STRVAR
(
_sre_ascii_iscased__doc__
,
"ascii_iscased($module, character, /)
\n
"
"--
\n
"
"
\n
"
);
#define _SRE_ASCII_ISCASED_METHODDEF \
{"ascii_iscased", (PyCFunction)_sre_ascii_iscased, METH_O, _sre_ascii_iscased__doc__},
static
int
_sre_ascii_iscased_impl
(
PyObject
*
module
,
int
character
);
static
PyObject
*
_sre_ascii_iscased
(
PyObject
*
module
,
PyObject
*
arg
)
{
PyObject
*
return_value
=
NULL
;
int
character
;
int
_return_value
;
if
(
!
PyArg_Parse
(
arg
,
"i:ascii_iscased"
,
&
character
))
{
goto
exit
;
}
_return_value
=
_sre_ascii_iscased_impl
(
module
,
character
);
if
((
_return_value
==
-
1
)
&&
PyErr_Occurred
())
{
goto
exit
;
}
return_value
=
PyBool_FromLong
((
long
)
_return_value
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
_sre_unicode_iscased__doc__
,
"unicode_iscased($module, character, /)
\n
"
"--
\n
"
"
\n
"
);
#define _SRE_UNICODE_ISCASED_METHODDEF \
{"unicode_iscased", (PyCFunction)_sre_unicode_iscased, METH_O, _sre_unicode_iscased__doc__},
static
int
_sre_unicode_iscased_impl
(
PyObject
*
module
,
int
character
);
static
PyObject
*
_sre_unicode_iscased
(
PyObject
*
module
,
PyObject
*
arg
)
{
PyObject
*
return_value
=
NULL
;
int
character
;
int
_return_value
;
if
(
!
PyArg_Parse
(
arg
,
"i:unicode_iscased"
,
&
character
))
{
goto
exit
;
}
_return_value
=
_sre_unicode_iscased_impl
(
module
,
character
);
if
((
_return_value
==
-
1
)
&&
PyErr_Occurred
())
{
goto
exit
;
}
return_value
=
PyBool_FromLong
((
long
)
_return_value
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
_sre_ascii_tolower__doc__
,
PyDoc_STRVAR
(
_sre_ascii_tolower__doc__
,
"ascii_tolower($module, character, /)
\n
"
"ascii_tolower($module, character, /)
\n
"
"--
\n
"
"--
\n
"
...
@@ -715,4 +777,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
...
@@ -715,4 +777,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyObject *Py_UNUSED(ignored))
{
{
return
_sre_SRE_Scanner_search_impl
(
self
);
return
_sre_SRE_Scanner_search_impl
(
self
);
}
}
/*[clinic end generated code: output=
811e67d7f8f5052e
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
5fe47c49e475cccb
input=a9049054013a1b77]*/
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