This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lemburg
Recipients belopolsky, cvrebert, eric.araujo, eric.smith, ezio.melotti, lemburg, mark.dickinson, ncoghlan, skrah, vstinner
Date 2013-06-14.07:53:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <51BACBF9.7050300@egenix.com>
In-reply-to <1371174218.35.0.775547858789.issue10581@psf.upfronthosting.co.za>
Content
On 14.06.2013 03:43, Alexander Belopolsky wrote:
> 
> Alexander Belopolsky added the comment:
> 
> PEP 393 implementation has already added the fast path to decimal encoding:
> 
> http://hg.python.org/cpython/diff/8beaa9a37387/Objects/unicodeobject.c#l1.3735
> 
> What we can do, however, is improve performance of converting non-ascii numerals by looking up only the first digit's value and converting the rest using simple:
> 
> value = code - (first_code - first_value)
> if not 0 <= value < 10:
>    raise or fall back to UCD lookup

I'm not sure whether just relying on PEP 393 is good enough.

Of course, you can special case the conversion based on the
kind, but that's only one form of optimization.

Slicing operations don't recheck the max code point
used in the substring. As a result, a slice may very well
be of the UCS2 kind, even though the text itself is ASCII.

Apart from the fast-path based on the string kind,
I think the decimal encoder would also have to scan the
string for non-ASCII code points. If it finds non-ASCII
code points, it would have to call the normalizer and
restart the scan based on the normalized string.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jun 14 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2013-07-01: EuroPython 2013, Florence, Italy ...           17 days to go
2013-07-16: Python Meeting Duesseldorf ...                 32 days to go

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
History
Date User Action Args
2013-06-14 07:53:40lemburgsetrecipients: + lemburg, mark.dickinson, ncoghlan, belopolsky, vstinner, eric.smith, ezio.melotti, eric.araujo, cvrebert, skrah
2013-06-14 07:53:40lemburglinkissue10581 messages
2013-06-14 07:53:39lemburgcreate