osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python 3.2 has some deadly infection


Le jeudi 5 juin 2014 11:53:00 UTC+2, Marko Rauhamaa a ?crit?:
> Chris Angelico <rosuav at gmail.com>:
> 
> 
> 
> > If the standard streams are so crucial, why are their most obvious
> 
> > interfaces insignificant to you?
> 
> 
> 
> I want the standard streams to consume and produce bytes. I do a lot of
> 
> system programming and connect processes to each other with socketpairs,
> 
> pipes and the like. I have dealt with plugin APIs that communicate over
> 
> stdin and stdout.
> 
> 
> 
> Python is clearly on a crusade to make *text* a first class system
> 
> entity. I don't believe that is possible (without casualties) in the
> 
> linux world. Python text should only exist inside string objects.
> 
> 
> 
> 
> 
> Marko

=====

Are you sure?

>>> timeit.repeat("(x*1000 + y)", setup="x = 'abc'; y = 'z'")
[0.9457552436453511, 0.9190932610143818, 0.9322044912393039]
>>> timeit.repeat("(x*1000 + y)", setup="x = 'abc'; y = '\u0fce'")
[2.5541921791045183, 2.52434366066052, 2.5337417948967413]
>>> timeit.repeat("(x*1000 + y)", setup="x = 'abc'.encode('utf-8'); y = 'z'.encode('utf-8')")
[0.9168235779232532, 0.8989583403075017, 0.8964204541650247]
>>> timeit.repeat("(x*1000 + y)", setup="x = 'abc'.encode('utf-8'); y = '\u0fce'.encode('utf-8')")
[0.9320969737165115, 0.9086006535332558, 0.9051715140790861]
>>> 
>>> 
>>> sys.getsizeof('abc'*1000 + '\u0fce')
6040
>>> sys.getsizeof(('abc'*1000 + '\u0fce').encode('utf-8'))
3020
>>>

jmf