[issue14719] Lists: [[0]*N]*N != [[0 for _ in range(N)] for __ in range(N)]

2012-05-03 Thread Ezio Melotti

Ezio Melotti  added the comment:

http://docs.python.org/faq/programming.html#how-do-i-create-a-multidimensional-list
http://python.net/crew/mwh/hacks/objectthink.html

--
nosy: +ezio.melotti
stage:  -> committed/rejected

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14720] sqlite3 microseconds

2012-05-03 Thread Frank Millman

New submission from Frank Millman :

sqlite3/dbapi2.py contains the following - 

def convert_timestamp(val): 
datepart, timepart = val.split(b" ")
timepart_full = timepart.split(b".")
[...] 
if len(timepart_full) == 2: 
microseconds = int(timepart_full[1]) 
else: 
microseconds = 0 

It assumes that 'timepart_full[1]' is a string containing 6 digits. 

I have a situation where the string containing 3 digits, so it gives the wrong 
result. For example, if the string is '456', this represents 456000 
microseconds, but sqlite3 returns 456 microseconds.

I think that it should right-zero-fill the string to 6 digits before converting 
to an int, like this - 

microseconds = int('{:0<6}'.format(timepart_full[1]))

--
components: Library (Lib)
messages: 159905
nosy: frankmillman
priority: normal
severity: normal
status: open
title: sqlite3 microseconds
type: behavior
versions: Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread Larry Hastings

Larry Hastings  added the comment:

> bba131e48852 causes crashes on Windows.
>
> The attached patch fixes the crash and makes test_os pass for me.
>
> However, using "PyErr_ExceptionMatches(PyExc_RuntimeError)" to check
> whether to try again using narrow strings is ugly.  Maybe
> utime_read_time_arguments() should be changed to have three possible
> return values.

I appreciate the feedback, and the patch.  And I agree--we should be able to 
find a better fix than that particular band-aid.  Can we hold off on checking 
in a patch for now?

TBH I don't understand why it should crash, and therefore how your patch helps. 
 Trying again using narrow strings should always work; indeed, the code did 
that before I touched it.  Can you describe how it crashes?

(p.s. Considering that I can't test on Windows myself, I'm pretty happy that 
the code works as well as it does!)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14719] Lists: [[0]*N]*N != [[0 for _ in range(N)] for __ in range(N)]

2012-05-03 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

It's actually fairly easy to explain. Just think about it harder (and consider 
Yuval's explanation).

--
nosy: +loewis
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14719] Lists: [[0]*N]*N != [[0 for _ in range(N)] for __ in range(N)]

2012-05-03 Thread Yuval Greenfield

Yuval Greenfield  added the comment:

This isn't a bug and should be closed. It's more of a stack overflow question.

If you'd like to change this fundamental behavior of a very common operation in 
python you should make a proposal to the python ideas mailing list at 
http://mail.python.org/mailman/listinfo/python-ideas

In your example board_2 is equivalent to:

row = [0] * N
board_2 = row * N

All the rows are the same initial row. As opposed to board_1 where each row is 
a new row.

Try this:

[id(i) for i in board_2]

The initial equivalence is because they do represent the same values (NxN list 
of all zeroes). What should python compare if not by values?

--
nosy: +ubershmekel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14710] pkgutil.get_loader is broken

2012-05-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14517] distutils always recompiles all C source files

2012-05-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14710] pkgutil.get_loader is broken

2012-05-03 Thread Nick Coghlan

Nick Coghlan  added the comment:

I'm not yet sure the proposed fix in the patch is the right approach (I need to 
look at the surrounding code), but I believe Pavel's right that get_loader() 
should be returning None in this case instead of throwing an exception.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14710] pkgutil.get_loader is broken

2012-05-03 Thread Pavel Aslanov

Pavel Aslanov  added the comment:

Main use case of pkgutil.get_loader is to determine if its possible to load 
module and either return loader or None. But it throws exception more over it 
is AttributeErrror exception.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14719] Lists: [[0]*N]*N != [[0 for _ in range(N)] for __ in range(N)]

2012-05-03 Thread Darrell Long

Changes by Darrell Long :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14719] Lists: [[0]*N]*N != [[0 for _ in range(N)] for __ in range(N)]

2012-05-03 Thread Darrell Long

New submission from Darrell Long :

N = 5
board_1 = [[0 for _ in range(N)] for __ in range(N)]

is not the same as:

board_2= [[0]*N]*N

One makes a proper list of lists (the first), the second makes a new kind of 
animal were board_2[1][1] = 99 changes a whole column.

Oddly, testing board_1 == board_2 is True!

I'm teaching Python to non-majors, and this is a tough one to explain.

--
components: Interpreter Core
files: Screen Shot 2012-05-03 at 9.05.59 PM.png
messages: 159899
nosy: darrell
priority: normal
severity: normal
status: open
title: Lists: [[0]*N]*N != [[0 for _ in range(N)] for __ in range(N)]
versions: Python 2.7
Added file: http://bugs.python.org/file25450/Screen Shot 2012-05-03 at 9.05.59 
PM.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14711] Remove os.stat_float_times

2012-05-03 Thread Éric Araujo

Éric Araujo  added the comment:

Let’s deprecate it in 3.3 then.

--
nosy: +eric.araujo
versions: +Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Éric Araujo

Éric Araujo  added the comment:

Added a few comments on Rietveld.

--
nosy: +eric.araujo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14715] test.support.DirsOnSysPath should be replaced by importlib.test.util.import_state

2012-05-03 Thread Éric Araujo

Éric Araujo  added the comment:

I tend to like context managers, or helpers that work with addCleanup, so that 
I keep the scaffolding next to the test code.  setUp and tearDown are better in 
some cases, though.  It is also possible to have an helper work as a decorator 
and a context manager and a setUp-tearDown thing with small effort.

--
nosy: +eric.araujo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14712] Integrate PEP 405

2012-05-03 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +eric.araujo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5372] Distutils inappropriately reuses .o files between extension modules

2012-05-03 Thread Éric Araujo

Éric Araujo  added the comment:

See also #14517.

--
nosy: +eric.araujo
resolution: accepted -> fixed
stage: patch review -> committed/rejected

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14517] distutils always recompiles all C source files

2012-05-03 Thread Éric Araujo

Éric Araujo  added the comment:

Hm, this change was done on purpose, because of the problems caused by stale 
object files (as explained on the other bug report), so it cannot just be 
reverted.  distutils is also under a feature freeze, only clear bugs warrant a 
change, so a performance improvement request like this must target distutils2, 
if we could find a good way to do it.

--
title: Recompilation of sources with Distutils -> distutils always recompiles 
all C source files

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14654] Faster utf-8 decoding

2012-05-03 Thread Éric Araujo

Changes by Éric Araujo :


--
title: More fast utf-8 decoding -> Faster utf-8 decoding

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Sam Rushing

Changes by Sam Rushing :


Added file: http://bugs.python.org/file25449/zlib_set_dictionary_3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Sam Rushing

Sam Rushing  added the comment:

Updated version of the patch: extends the test, including a test of the 
streaming behavior needed for SPDY (both compression and decompression).

Also wik: copy()/uncopy() are aware of the 'dict' attribute.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14711] Remove os.stat_float_times

2012-05-03 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

> Is there a specific reason this is still around?

I forgot to remove it for Python 3, and now it can only be removed through a 
deprecation cycle.

--
nosy: +loewis

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread Richard Oudkerk

Richard Oudkerk  added the comment:

bba131e48852 causes crashes on Windows.

The attached patch fixes the crash and makes test_os pass for me.

However, using "PyErr_ExceptionMatches(PyExc_RuntimeError)" to check whether to 
try again using narrow strings is ugly.  Maybe utime_read_time_arguments() 
should be changed to have three possible return values.

--
nosy: +sbt
Added file: http://bugs.python.org/file25448/utime-hack.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Sam Rushing

Sam Rushing  added the comment:

Argh, probably need to add the 'dict' field to the copy() method.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Sam Rushing

Sam Rushing  added the comment:

This test is rather large, since it includes the predefined SPDY draft 2 
dictionary, and some real-world data.  Not sure what the policy is on including 
so much data in a test.  If there's enough time I could make a smaller test 
that also verifies the correct behavior on a stream...

--
Added file: http://bugs.python.org/file25447/tz2.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Sam Rushing

Sam Rushing  added the comment:

Ok, here's the patch.  It has a single short test.  For use with SPDY, it's 
necessary to test that the following stream data also correctly decompresses, 
I'll attach that to the next comment.

--
Added file: http://bugs.python.org/file25446/zlib_set_dictionary_2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
assignee: serwy -> 
nosy:  -serwy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Jesús Cea Avión

Jesús Cea Avión  added the comment:

Retargetting to python 3.3.

If you hurry a bit and I find your patch acceptable (remember the tests!), I 
will try to integrate it.

--
assignee:  -> serwy
nosy: +serwy
versions: +Python 3.3 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Sam Rushing

Sam Rushing  added the comment:

I'm currently reworking this so that the dictionaries are provided in the 
constructor, and inflateSetDictionary() is called automatically.  I've gone 
over the zlib RFC's and zlibmodule.c, and I'm fairly certain that whatever 
usage mode might involve multiple calls to SetDictionary() couldn't be 
supported by the zlib object anyway.

r.e. 3.3/3.4 - I merely chose the highest version number I saw, since this diff 
is against HEAD (as recommended by the docs).  It's been quite a few years 
since I've submitted a patch to CPython!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14717] In generator's .close() docstring there is one argument

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset b8c1cabcd115 by Benjamin Peterson in branch '3.2':
close() doesn't take any args (closes #14717)
http://hg.python.org/cpython/rev/b8c1cabcd115

New changeset b2031eb95dd9 by Benjamin Peterson in branch '2.7':
close() doesn't take any args (closes #14717)
http://hg.python.org/cpython/rev/b2031eb95dd9

New changeset da12cb2461d1 by Benjamin Peterson in branch 'default':
merge 3.2 (#14717)
http://hg.python.org/cpython/rev/da12cb2461d1

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14716] Use unicode_writer API for str.format()

2012-05-03 Thread Eric V. Smith

Changes by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14718] In the generator's try/finally statement a runtime error occurs when the generator is not exhausted

2012-05-03 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

It means in the body of the try statement.

--
nosy: +benjamin.peterson
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14718] In the generator's try/finally statement a runtime error occurs when the generator is not exhausted

2012-05-03 Thread py.user

New submission from py.user :

http://www.python.org/dev/peps/pep-0342/
" 6. Allow "yield" to be used in try/finally blocks, since garbage
   collection or an explicit close() call would now allow the
   finally clause to execute."

"New syntax: yield allowed inside try-finally

The syntax for generator functions is extended to allow a
yield-statement inside a try-finally statement."


>>> def f():
...   try:
... yield 1
... yield 2
... yield 3
...   finally:
... yield 4
... 
>>> g = f()
>>> next(g)
1
>>> next(g)
2
>>> g = f()
Exception RuntimeError: 'generator ignored GeneratorExit' in  ignored
>>>

--
components: Interpreter Core
messages: 159883
nosy: py.user
priority: normal
severity: normal
status: open
title: In the generator's try/finally statement a runtime error occurs when the 
generator is not exhausted
type: behavior
versions: Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14717] In generator's .close() docstring there is one argument

2012-05-03 Thread py.user

New submission from py.user :

>>> g

>>> print(g.close.__doc__)
close(arg) -> raise GeneratorExit inside generator.
>>> g.close(1)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: close() takes no arguments (1 given)
>>>

--
assignee: docs@python
components: Documentation
messages: 159882
nosy: docs@python, py.user
priority: normal
severity: normal
status: open
title: In generator's .close() docstring there is one argument
versions: Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14711] Remove os.stat_float_times

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

> Is there a specific reason this is still around?

Not really, it just that nobody noticed it :-)

We can deprecate it, but it is maybe safer to not remove it.

Note: os.stat() has now new st_*time_ns fields with a nanosecond resolution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14716] Use unicode_writer API for str.format()

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

Oh, I forgot the benchmark script:

$ cat ~/bench_format.sh 
./python -m timeit \
-s 'fmt="{}:"; arg="abc"' \
'fmt.format(arg)'
./python -m timeit \
-s 'N=200; L=3; fmt="{}"*N; args=("a"*L,)*N' \
'fmt.format(*args)'
./python -m timeit \
-s 's="x=%s, y=%u, z=%x"; args=(123, 456, 789)' \
's.format(*args)'
./python -m timeit \
-s 's="The {k1} is {k2} the {k3}."; args={"k1": "x", "k2": "y", "k3": "z"}' 
\
's.format(**args)'

(based on the one used for #14687, see msg159822)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14716] Use unicode_writer API for str.format()

2012-05-03 Thread STINNER Victor

New submission from STINNER Victor :

I just added a new "unicode_writer" API for the issue #14687 (Optimize 
str%tuple for the PEP 393) which helps to make "str%tuple" between 25% and 30% 
faster.

Attached patch replaces PyAccu API with the unicode_writer API for str.format().

Python 3.2:

100 loops, best of 3: 0.198 usec per loop
10 loops, best of 3: 11.3 usec per loop
1000 loops, best of 3: 0.167 usec per loop
100 loops, best of 3: 0.494 usec per loop

Python 3.3:

100 loops, best of 3: 0.293 usec per loop
1 loops, best of 3: 20.2 usec per loop
100 loops, best of 3: 0.219 usec per loop
100 loops, best of 3: 0.909 usec per loop

Python 3.3 + patch (speed up of the patch):

100 loops, best of 3: 0.226 usec per loop (-22%)
10 loops, best of 3: 14.8 usec per loop (-26%)
100 loops, best of 3: 0.219 usec per loop (0%)
100 loops, best of 3: 0.658 usec per loop (-27%)

--
components: Interpreter Core
files: unicode_format_writer.patch
keywords: patch
messages: 159879
nosy: haypo, kristjan.jonsson, loewis, pitrou, python-dev, storchaka
priority: normal
severity: normal
status: open
title: Use unicode_writer API for str.format()
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file25445/unicode_format_writer.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14715] test.support.DirsOnSysPath should be replaced by importlib.test.util.import_state

2012-05-03 Thread Brett Cannon

Brett Cannon  added the comment:

Yes, it could do all of this. One possibility that I was thinking of, was this 
could be a setUp()/tearDown() thing as well instead of a context manager. 
Another option is a simple decorator. Either way it might be easier to have it 
just save state and then in the body of the code set everything as desired 
instead of in the context manager's init.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

>> because I read that realloc() on Windows is not efficient.
> Efficiency is not a Boolean property, you know :)  Anyway,
> I´d be surprised if it were very iniefficient, given that
> the heap allocators on Windows are quite mature by now.

My benchmark is more a *micro* benchmark on some very basic cases (short ASCII 
strings). But it looks like overallocating *helps*. In the following example, 
only two resize are needed:

./python -m timeit \
-s 'N=200; L=3; fmt="%s"*N; args=("a"*L,)*N' \
'fmt % args'

len(fmt)+100 = 500 characters are allocated for the initial buffer. Writing the 
501st character enlarges the buffer to 626 characters: first resize. The output 
string is truncated to 600 characters: second and final resize.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14712] Integrate PEP 405

2012-05-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14711] Remove os.stat_float_times

2012-05-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Kristján Valur Jónsson

Kristján Valur Jónsson  added the comment:

> because I read that realloc() on Windows is not efficient.
Efficiency is not a Boolean property, you know :)  Anyway, I´d be surprised if 
it were very iniefficient, given that the heap allocators on Windows are quite 
mature by now.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Python 3.3 @ 1439e2d1f490:
> 
> 100 loops, best of 3: 0.265 usec per loop
> 10 loops, best of 3: 11 usec per loop
> 100 loops, best of 3: 0.961 usec per loop
> 100 loops, best of 3: 0.924 usec per loop
> 
> Python 3.3 @ cdc4e0f8135d:
> 
> 1000 loops, best of 3: 0.154 usec per loop
> 10 loops, best of 3: 7.85 usec per loop
> 100 loops, best of 3: 0.583 usec per loop
> 100 loops, best of 3: 0.535 usec per loop

Very nice, thank you!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8536] Support new features of ZLIB 1.2.7

2012-05-03 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
title: Support new features of ZLIB 1.2.6 -> Support new features of ZLIB 1.2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

Results on Windows Seven 64 bits, on Intel i7 2600 @ 3.4 GHz (8 cores), Windows 
running in a virtual machine (kvm) with hardware virtualization.

Python 3.2.2:

1000 loops, best of 3: 0.12 usec per loop
10 loops, best of 3: 5.12 usec per loop
100 loops, best of 3: 0.581 usec per loop
100 loops, best of 3: 0.397 usec per loop

Python 3.3 @ 1439e2d1f490:

100 loops, best of 3: 0.265 usec per loop
10 loops, best of 3: 11 usec per loop
100 loops, best of 3: 0.961 usec per loop
100 loops, best of 3: 0.924 usec per loop

Python 3.3 @ cdc4e0f8135d:

1000 loops, best of 3: 0.154 usec per loop
10 loops, best of 3: 7.85 usec per loop
100 loops, best of 3: 0.583 usec per loop
100 loops, best of 3: 0.535 usec per loop

To be honest, I'm surprised that my work speeds up Python 3.3 on Windows, 
because I read that realloc() on Windows is not efficient. It is maybe no more 
true with Windows Seven? It would be interesting if someone could run the 
benchmark on Windows XP or 2000.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14715] test.support.DirsOnSysPath should be replaced by importlib.test.util.import_state

2012-05-03 Thread Eric V. Smith

New submission from Eric V. Smith :

DirsOnSysPath doesn't clear sys.path_importer_cache, so it seems you'd always 
want to use import_state, which does clear it.

We might also want to modify import_state to remember the original objects, not 
just their values. DirsOnSysPath does do this, for sys.path.

If we do this, we should probably move import_state to test.support.

Also, couldn't import_state do with sys.modules what DirsOnSysPath does with 
sys.path? It could restore both the object and its contents.

--
messages: 159873
nosy: barry, brett.cannon, eric.smith, jason.coombs
priority: normal
severity: normal
status: open
title: test.support.DirsOnSysPath should be replaced by 
importlib.test.util.import_state
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

> Do you think that this optimization is relevant to 2.7?

No, this is just an attempt to deal with the shortcomings of PEP 393.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset cdc4e0f8135d by Larry Hastings in branch 'default':
Issue #14127: Fix no-op stub for platforms that lack some "os" functions.
http://hg.python.org/cpython/rev/cdc4e0f8135d

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14684] zlib set dictionary support inflateSetDictionary

2012-05-03 Thread Jesús Cea Avión

Jesús Cea Avión  added the comment:

A dictionary could be provided an init time. Then, the Z_NEED_DICT could be 
intercepted in the binding and automatically inject the dictionary provided in 
the init.

Anyway, for a patch to be approved, we need a test too.

PS: Why is this NOT targeted to 3.3?. We have time, yet.

--
nosy: +jcea

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Kristján Valur Jónsson

Kristján Valur Jónsson  added the comment:

Do you think that this optimization is relevant to 2.7?
In that case, it might be worthwhile for me to backport it to our EVE branch...

--
nosy: +kristjan.jonsson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5118] '%.2f' % 2.545 doesn't round correctly

2012-05-03 Thread Mark Dickinson

Mark Dickinson  added the comment:

> That's because Python uses floating point registers of the x86-CPU-
> architecture to store point values. This method is inaccurate and causes
> such problems.

Yes, exactly;  this is the root cause.

And as you suggest, Python *could* use a different numeric storage format that 
doesn't suffer from loss of information when initializing a number from a 
decimal string.  There's an obvious candidate for that storage format, and 
that's the decimal.Decimal type.

There are some issues, though:

(1) decimal.Decimal operations are implemented in software (in pure Python for 
versions <= 3.2, and now in C in Python 3.3) and so are orders of magnitude 
slower than hardware-supported floats.  That's one of the reasons that almost 
every mainstream programming language uses the binary-represented hardware 
floats as the main way of representing non-integral numbers.  The need for 
those fast floats isn't going to go away in a hurry.  The obvious solution here 
would be to for Python to support both binary floats and decimal floats, and 
perhaps to make numeric literals default to being decimal.Decimal instances.

(2) Getting to the point where the Decimal type could be used for numeric 
literals will be a *long* road, full of backwards compatibility concerns, PEPs, 
and long and probably contentious python-dev discussions.  Python's just taken 
the first step along that road by reimplementing the decimal module in C for 
Python 3.3;  this improves the speed significantly (though floats are still 
significantly more efficient in both time and space, and likely will be for a 
long time), and also makes it easier to start using decimal more widely from 
within the core of Python.

Reaching that point of having the Decimal type more fully integrated into 
Python is something that I know a good few of the Python developers are 
interested in (including me).  But it's not going to be an easy or quick change.

> @Mark: And I am also one of thouse who lost a lot of interrest in helping out 
> in the futher development of
> Python. It was because your haughtiness.

I see how my earlier messages came across badly.  I apologise for that, and I 
hope you won't let the poorly chosen words of just one Python developer out of 
many put you off future involvement in Python.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset f58159e5d52f by Victor Stinner in branch 'default':
Issue #14687: Remove redundant length attribute of unicode_write_t
http://hg.python.org/cpython/rev/f58159e5d52f

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14707] extend() puzzled me.

2012-05-03 Thread Daniel543

Daniel543  added the comment:

Thank u both.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14713] PEP 414 installation hook fails with an AssertionError

2012-05-03 Thread Vinay Sajip

Changes by Vinay Sajip :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14713] PEP 414 installation hook fails with an AssertionError

2012-05-03 Thread Vinay Sajip

New submission from Vinay Sajip :

I'm not sure if I've done something wrong, but I get an AssertionError when 
trying to run the tokenizer on a Python file from the Django source. The gist 
at https://gist.github.com/1977558 has the files concerned:

1. test_tokenize.py - the script which fails
2. tokenize_example.py - the file being tokenized and untokenized. This is from 
the Django source: django/extras/csrf_migration_helper.py
3. tokenizer.py - your tokenize module, I renamed it because I was working in 
/tmp and didn't want to import the Python 3.2 stdlib's tokenize.py
4. The test output shows that the tokenize_example module imports OK in Python 
2.7.2, but running the test_tokenize script on it with Python3.2 fails with an 
AssertionError.

I did some more testing, there are 131 failures in the Django source tree (all 
look like the same AssertionError).

N.B. I posted this to your GitHub repo where you published the hook.

--
messages: 159864
nosy: aronacher, vinay.sajip
priority: normal
severity: normal
status: open
title: PEP 414 installation hook fails with an AssertionError

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14714] PEp 414 tokenizing hook does not preserve tabs

2012-05-03 Thread Vinay Sajip

New submission from Vinay Sajip :

Tabs in Python source are a no-no for me and lots of other people, but some 
people do use them. The tokenizer seems to not preserve tabs in its output. 
There are some tabs in the Django source, for example 
tests/regressiontests/localflavor/pl/tests.py.

N.B. I posted this to your GitHub repo where you published the hook.

--
messages: 159865
nosy: aronacher, vinay.sajip
priority: normal
severity: normal
status: open
title: PEp 414 tokenizing hook does not preserve tabs
type: behavior
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14712] Integrate PEP 405

2012-05-03 Thread Vinay Sajip

Changes by Vinay Sajip :


--
keywords: +patch
Added file: http://bugs.python.org/file25444/c82881ad6b6f.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14712] Integrate PEP 405

2012-05-03 Thread Vinay Sajip

Changes by Vinay Sajip :


--
hgrepos: +120

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14712] Integrate PEP 405

2012-05-03 Thread Vinay Sajip

New submission from Vinay Sajip :

This issue will track implementation of PEP 405 functionality.

--
assignee: vinay.sajip
messages: 159863
nosy: vinay.sajip
priority: normal
severity: normal
status: open
title: Integrate PEP 405
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14632] Race condition in WatchedFileHandler leads to unhandled exception

2012-05-03 Thread Vinay Sajip

Vinay Sajip  added the comment:

I noticed that in my cleanup code, I had the lines

h.close()
remover.join()

but it makes more sense for these to be in the opposite order. I've made that 
changed and pushed it up (for 2.7, 3.2 and default).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14710] pkgutil.get_loader is broken

2012-05-03 Thread Brett Cannon

Brett Cannon  added the comment:

So I'm no pkgutil expert, but at least in the case of None in sys.modules, that 
triggers at least an ImportError in __import__ if that is come across.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14711] Remove os.stat_float_times

2012-05-03 Thread R. David Murray

R. David Murray  added the comment:

Victor proposed deprecating it as part of PEP 410 (see issue 13882), but the 
PEP was rejected for other reasons.

--
nosy: +haypo, r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14711] Remove os.stat_float_times

2012-05-03 Thread Armin Ronacher

New submission from Armin Ronacher :

Is there a specific reason this is still around?  Originally that was to make 
it possible to upgrade to Python 2.3 or whenever that was introduced.  I don't 
think anyone still uses that.

--
messages: 159859
nosy: aronacher
priority: normal
severity: normal
status: open
title: Remove os.stat_float_times
versions: Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14624] Faster utf-16 decoder

2012-05-03 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Here is updated patch, taking into account that unicode_widen is already
optimized.

--
Added file: http://bugs.python.org/file25443/decode_utf16_2.patch

___
Python tracker 

___diff -r 0a9143d7b097 Objects/stringlib/asciilib.h
--- a/Objects/stringlib/asciilib.h  Thu May 03 13:43:07 2012 +0200
+++ b/Objects/stringlib/asciilib.h  Thu May 03 15:50:11 2012 +0300
@@ -7,6 +7,7 @@
 #define STRINGLIB(F) asciilib_##F
 #define STRINGLIB_OBJECT PyUnicodeObject
 #define STRINGLIB_SIZEOF_CHAR1
+#define STRINGLIB_MAX_CHAR   0x7Fu
 #define STRINGLIB_CHAR   Py_UCS1
 #define STRINGLIB_TYPE_NAME  "unicode"
 #define STRINGLIB_PARSE_CODE "U"
diff -r 0a9143d7b097 Objects/stringlib/codecs.h
--- a/Objects/stringlib/codecs.hThu May 03 13:43:07 2012 +0200
+++ b/Objects/stringlib/codecs.hThu May 03 15:50:11 2012 +0300
@@ -150,7 +150,6 @@
 return ret;
 }
 
-#undef LONG_PTR_MASK
 #undef ASCII_CHAR_MASK
 
 
@@ -350,4 +349,153 @@
 #undef MAX_SHORT_UNICHARS
 }
 
+#define UCS2_REPEAT_MASK(~0ul / 0xul)
+
+/* The mask for fast checking of whether a C 'long' may contain
+   UTF16-encoded surrogate characters. This is an efficient heuristic,
+   assuming that non-surrogate characters with a code point >= 0x8000 are
+   rare in most input.
+*/
+#if STRINGLIB_SIZEOF_CHAR == 1
+# define FAST_CHAR_MASK (UCS2_REPEAT_MASK * (0xu & 
~STRINGLIB_MAX_CHAR))
+#else
+# define FAST_CHAR_MASK (UCS2_REPEAT_MASK * 0x8000u)
+#endif
+/* The mask for fast byteswapping. */
+#define STRIPPED_MASK   (UCS2_REPEAT_MASK * 0x00FFu)
+/* Swap bytes. */
+#define SWAB(value) value) >> 8) & STRIPPED_MASK) | \
+ (((value) & STRIPPED_MASK) << 8))
+
+Py_LOCAL_INLINE(Py_UCS4)
+STRINGLIB(utf16_try_decode)(STRINGLIB_CHAR *dest, Py_ssize_t *outpos,
+const unsigned char **inptr,
+const unsigned char *e,
+int native_ordering)
+{
+const unsigned char *aligned_end =
+(const unsigned char *) ((size_t) (e + 1) & ~LONG_PTR_MASK);
+const unsigned char *q = *inptr;
+STRINGLIB_CHAR *p = dest + *outpos;
+/* Offsets from q for retrieving byte pairs in the right order. */
+#ifdef BYTEORDER_IS_LITTLE_ENDIAN
+int ihi = !!native_ordering, ilo = !native_ordering;
+#else
+int ihi = !native_ordering, ilo = !!native_ordering;
+#endif
+
+while (q < e) {
+Py_UCS4 ch;
+/* First check for possible aligned read of a C 'long'. Unaligned
+   reads are more expensive, better to defer to another iteration. */
+if (!((size_t) q & LONG_PTR_MASK)) {
+/* Fast path for runs of non-surrogate chars. */
+register const unsigned char *_q = q;
+while (_q < aligned_end) {
+unsigned long block = * (unsigned long *) _q;
+/* Fast checking of whether a C 'long' may contain
+   UTF16-encoded surrogate characters. This is an efficient
+   heuristic, assuming that non-surrogate characters with
+   a code point >= 0x8000 are rare in most input.
+*/
+if (native_ordering) {
+/* Can use buffer directly */
+if (block & FAST_CHAR_MASK)
+break;
+}
+else {
+/* Need to byte-swap */
+if (block & SWAB(FAST_CHAR_MASK))
+break;
+#if STRINGLIB_SIZEOF_CHAR == 1
+block >>= 8;
+#else
+block = SWAB(block);
+#endif
+}
+#ifdef BYTEORDER_IS_LITTLE_ENDIAN
+#if SIZEOF_LONG == 4
+*(p + 0) = (STRINGLIB_CHAR)(block & 0xu);
+*(p + 1) = (STRINGLIB_CHAR)(block >> 16);
+#endif
+#if SIZEOF_LONG == 8
+*(p + 0) = (STRINGLIB_CHAR)(block & 0xu);
+*(p + 1) = (STRINGLIB_CHAR)((block >> 16) & 0xu);
+*(p + 2) = (STRINGLIB_CHAR)((block >> 32) & 0xu);
+*(p + 3) = (STRINGLIB_CHAR)(block >> 48);
+#endif
+#else
+#if SIZEOF_LONG == 4
+*(p + 0) = (STRINGLIB_CHAR)(block >> 16);
+*(p + 1) = (STRINGLIB_CHAR)(block & 0xu);
+#endif
+#if SIZEOF_LONG == 8
+*(p + 0) = (STRINGLIB_CHAR)(block >> 48);
+*(p + 1) = (STRINGLIB_CHAR)((block >> 32) & 0xu);
+*(p + 2) = (STRINGLIB_CHAR)((block >> 16) & 0xu);
+*(p + 3) = (STRINGLIB_CHAR)(block & 0xu);
+#endif
+#endif
+_q += SIZEOF_LONG;
+p += SIZEOF_LONG / 2;
+}
+q = _q;
+if (q >= e)
+break;
+}
+ch = 

[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

http://www.python.org/dev/buildbot/all/builders/AMD64%20OpenIndiana%203.x/builds/3388/steps/test/logs/stdio

ERROR: test_copy2_symlinks (test.test_shutil.TestShutil)
--
Traceback (most recent call last):
  File 
"/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_shutil.py",
line 328, in test_copy2_symlinks
shutil.copy2(src_link, dst, symlinks=True)
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/shutil.py",
line 193, in copy2
copystat(src, dst, symlinks=symlinks)
  File "/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/shutil.py",
line 157, in copystat
utime_func(dst, ns=(st.st_atime_ns, st.st_mtime_ns))
TypeError: _nop() got an unexpected keyword argument 'ns'

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

> Results on 32 bits (Intel Core i5 CPU 661 @ 3.33GHz) on Linux 3.0 with a new 
> patch.

Your tests only for ascii. You should also see some of corner cases --
a large format string and a few small arguments (templating),
a small simple format string and one large argument
(idiomatic `'[%s]' % ', '.join(long_list)`).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> > It would be nice to have measurements under Windows.
> 
> The differences between 32-bit Linux and 32-bit Windows should not be.

The Windows memory allocator is quite different from the glibc's, so the
overallocation / resizing approach may play differently.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

> It would be nice to have measurements under Windows.

The differences between 32-bit Linux and 32-bit Windows should not be.
But 64-bit can be different, and 64-bit Linux and 64-bit Windows can
vary from 32-bit, and from each other. There are also differences
between high-end Intel Core and low-end Intel Atom, and AMD processors.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5118] '%.2f' % 2.545 doesn't round correctly

2012-05-03 Thread Ultrasick

Ultrasick  added the comment:

Ok, let's sum that up:

There is a rounding problem. That's because Python uses floating point 
registers of the x86-CPU-architecture to store point values. This method is 
inaccurate and causes such problems. So Python inherits this bug from this 
value storing method.

Even thou the origin of this bug is in the method which is beeing used, Python 
has inherited this bug and can't round correctly.

If we would say that Python does not support point values but only floating 
point values of the x86-CPU-architecture (so not even floating point values in 
general) then we could admit that round(2.545, 2) has a bug because it 
"incorrectly" shows 2.55 as the result. But that wouldn't help us any further.

One possible solution would be to use a different method to store point values. 
For exaple 2 integers could be used to store a point value lossless. The one 
integer stores whatever is left of the point and the other integer stores 
whatever is right of the point. Meaning:

25.0:
-> integer #1: 0,000,000,025
-> integer #2: 0,000,000,000

25.7:
-> integer #1: 0,000,000,025
-> integer #2: 0,999,970,000

25.1
-> integer #1: 0,000,000,025
-> integer #2: 0,000,010,000

As you can see, this method is lossless. As long as you don't try to store more 
than 32 significant bits in a register which is 32 bits in size. To be more 
accurate: you can't even use all 32 bits because the most significant digit can 
only be between 0 and 4 (4,294,967,295 barrier).

Using this value storing method would mean quite some efforts for the 
developers. But then Python would be able to round correctly. So that's why I 
call it a "possible solution".

I am not the one who is going to make the decision, whether a different 
value-storing-method is going to be implemented, indepentend how this value 
storing method may look like. But I am one of thouse who suffered from the 
method which is currently implemented.

@Mark: And I am also one of thouse who lost a lot of interrest in helping out 
in the futher development of Python. It was because your haughtiness. You tried 
to show how perfect Python is and that there would be no bugs. But your last 
comment was a little more productive. Even thou you still haven't showed much 
interest in finding a solution to the problem.

@Zeev: I already gave up. But you had more endurance. Thanks :-)

Gary

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 0a9143d7b097 by Victor Stinner in branch 'default':
Issue #14687: Cleanup unicode_writer_prepare()
http://hg.python.org/cpython/rev/0a9143d7b097

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Results on 32 bits (Intel Core i5 CPU 661 @ 3.33GHz) on Linux 3.0 with
> a new patch.

It would be nice to have measurements under Windows.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread STINNER Victor

Changes by STINNER Victor :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset f1db931b93d3 by Victor Stinner in branch 'default':
Issue #14687: str%tuple now uses an optimistic "unicode writer" instead of an
http://hg.python.org/cpython/rev/f1db931b93d3

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

Results on 32 bits (Intel Core i5 CPU 661 @ 3.33GHz) on Linux 3.0 with a new 
patch.

Python 3.2:
 
1000 loops, best of 3: 0.133 usec per loop
10 loops, best of 3: 4.64 usec per loop
100 loops, best of 3: 0.637 usec per loop
100 loops, best of 3: 0.364 usec per loop

Python 3.3 @ 1439e2d1f490 (before my first optimization on str%tuple):

1000 loops, best of 3: 0.193 usec per loop
10 loops, best of 3: 10.1 usec per loop
100 loops, best of 3: 0.838 usec per loop
100 loops, best of 3: 0.825 usec per loop

Python 3.3 + patch, overallocate 50%:

1000 loops, best of 3: 0.15 usec per loop
10 loops, best of 3: 8.27 usec per loop
100 loops, best of 3: 0.527 usec per loop
100 loops, best of 3: 0.566 usec per loop

Python 3.3 + patch, overallocate 25%:

1000 loops, best of 3: 0.142 usec per loop
10 loops, best of 3: 7.93 usec per loop
100 loops, best of 3: 0.532 usec per loop
100 loops, best of 3: 0.546 usec per loop

I'm going to commit the new patch with an overallocation of 25%.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14709] http.client fails sending read()able Object

2012-05-03 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +orsenthil

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14710] pkgutil.get_loader is broken

2012-05-03 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +brett.cannon, ncoghlan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14710] pkgutil.get_loader is broken

2012-05-03 Thread Pavel Aslanov

New submission from Pavel Aslanov :

if module was marked as not existing by setting sys.modules [fullname] to None, 
then pkgutil.get_loader (fullname) will throw AttributeError.

Example:
#! /usr/bin/evn python
import unittest
import pkgutil

def main ():
pkgutil.get_loader ('unittest.functools')

if __name__ == '__main__':
main ()

Patch is attached

--
components: Library (Lib)
files: python_pkgutil_bug.patch
keywords: patch
messages: 159848
nosy: Pavel.Aslanov
priority: normal
severity: normal
status: open
title: pkgutil.get_loader is broken
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file25442/python_pkgutil_bug.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14687] Optimize str%tuple for the PEP 393

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 830eeff4fe8f by Victor Stinner in branch 'default':
Issue #14624, #14687: Optimize unicode_widen()
http://hg.python.org/cpython/rev/830eeff4fe8f

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14624] Faster utf-16 decoder

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 830eeff4fe8f by Victor Stinner in branch 'default':
Issue #14624, #14687: Optimize unicode_widen()
http://hg.python.org/cpython/rev/830eeff4fe8f

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14709] http.client fails sending read()able Object

2012-05-03 Thread Tobias Steinrücken

New submission from Tobias Steinrücken :

It seems that http.client's send() function lacks an else/return statement in 
Line 772.
If this method is called with an read()able Object, it jumps into 

L 750: if hasattr( data,"read"):

processes this data correctly, but then falls through (due to missing else ) to

L 773: try:
L 774: self.socket.sendall(data)

where finally an TypeError raises.

--
components: None
messages: 159845
nosy: Tobias.Steinrücken
priority: normal
severity: normal
status: open
title: http.client fails sending read()able Object
type: behavior
versions: Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14705] Add 'bool' format character to PyArg_ParseTuple*

2012-05-03 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Patch looks good to me.

I however prefer to use 'P'.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11839] argparse: unexpected behavior of default for FileType('w')

2012-05-03 Thread Paolo Elvati

Changes by Paolo Elvati :


--
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11839] argparse: unexpected behavior of default for FileType('w')

2012-05-03 Thread Paolo Elvati

Changes by Paolo Elvati :


--
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11839] argparse: unexpected behavior of default for FileType('w')

2012-05-03 Thread Paolo Elvati

Changes by Paolo Elvati :


--
resolution:  -> duplicate
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14708] distutils's checking for MSVC compiler

2012-05-03 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

In any case, it appears that there is no bug report in this issue, so I'm 
closing this as "works for me".

--
resolution:  -> works for me
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14708] distutils's checking for MSVC compiler

2012-05-03 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

DISTUTILS_USE_SDK really means "shut up, I know what I'm doing". So if this is 
the case (i.e. you *really* know what you are doing), just set MsSdk as well.

I don't actually know whether the latest SDK is able to build correct 
extensions for Python 2.7 - I haven't looked at the latest SDK. It may be that 
MS stopped setting MsSdk for a reason.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8077] cgi handling of POSTed files is broken

2012-05-03 Thread Senthil Kumaran

Changes by Senthil Kumaran :


--
assignee:  -> orsenthil
nosy: +orsenthil

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread Larry Hastings

Larry Hastings  added the comment:

We don't!

The test that failed compares the ns_[amc]time and ns_[amc]time_ns fields to 
ensure they're roughly equivalent.  Note that the former fields are floats, 
which by now ought not to be news to you.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread STINNER Victor

STINNER Victor  added the comment:

> The OpenIndiana buildbot was bit by a rounding error.

How do we have rounding issue with only integers?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14705] Add 'bool' format character to PyArg_ParseTuple*

2012-05-03 Thread Larry Hastings

Larry Hastings  added the comment:

My first patch.  Adds 'p' and 'P', along with documentation and unit tests.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file25441/larry.parse.tuple.p.and.P.1.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8077] cgi handling of POSTed files is broken

2012-05-03 Thread Pierre Quentel

Pierre Quentel  added the comment:

There are 2 different problems :
- handling of data by cgi.FieldStorage (issue 4953) : fixed since version 3.2
- in http.server.CGIHTTPRequestHandler, for POST requests on Windows, before 
opening the subprocess in run_cgi() all data is read by a *single* call to 
self.rfile.read(). If not all bytes are read by this single call, which is the 
case for a large file upload, only the read data are processed

The attached patch modifies http.server :
- if all data are read in the first call to self.rfile.read() (that is, if its 
length is equal to the Content-length header), process them
- if not, store all data in a temporary file (not in memory) and set the stdin 
argument of subprocess.Popen to this temporary file

With this patch, the tests provided by Mitchell all work on my PC (Windows XP 
Pro SP3)

--
keywords: +patch
Added file: http://bugs.python.org/file25440/http-server.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread Larry Hastings

Larry Hastings  added the comment:

@haypo: Thanks for pointing that out buildbot failure!  The OpenIndiana 
buildbot was bit by a rounding error.  I fixed it by adding in a fudge factor 
it--I snuck in one last change just now.  I weakened the unit test as follows:

-self.assertEqual(floaty, nanosecondy)
+self.assertAlmostEqual(floaty, nanosecondy, delta=2)

Also: I'm leaving this issue open for now, to remind myself to add ns= to  
utimensat and futimesat if they're still alive on June 15th.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14127] add st_*time_ns fields to os.stat(), add ns keyword to os.*utime*(), os.*utimens*() expects a number of nanoseconds

2012-05-03 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset bba131e48852 by Larry Hastings in branch 'default':
Issue #14127: Add ns= parameter to utime, futimes, and lutimes.
http://hg.python.org/cpython/rev/bba131e48852

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14708] distutils's checking for MSVC compiler

2012-05-03 Thread jamesf

jamesf <54740...@qq.com> added the comment:

Thanks for your replying.

Here is my understanding of how the compiler chosen logic works, correct me if 
i am wrong:
1) If using MSVC, we should ALWAYS stick the compiler to the version which 
python was compiled with;
2) But we can change SDK version through DISTUTILS_USE_SDK with SetEnv.cmd 
already called.
3) It's the compiler version that matters, not SDK version.

But from distutils source:

if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and ...:
^
does this mean i can not use lastest SDK since it does not set MSSdk variable?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com