Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Tim Peters
[nha pham ] > Thank you very much. I am very happy that I got a reply from Tim Peter. My pleasure to speak with you too :-) > You are correct, my mistake. > > The python code should be: > for i in range(low+1,high): //because we already add > data[low] > x = data[i] >

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread nha pham
Thank you very much. I am very happy that I got a reply from Tim Peter. You are correct, my mistake. The python code should be: for i in range(low+1,high): //because we already add data[low] x = data[i] if x >= data[i-1]: After I fix it, here is the result: rand

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Tim Peters
[nha pham ] > Statement_1: With an array of size N or less than N, we need at most log2(N) > comparisons to find a value > (or a position, incase the search miss), using the binary search algorithm. > > proof: This statement is trivia, and I believe, someone outthere already > proved it. Sorry for

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread nha pham
Thank you for your comment. I admit that I did not thinking about the proof before. Here is my naive proof. I hope you can give me some comments: = # This proof is an empirical thinking and is not completed, it just gives us a closer look. I hope someone can make it more mathematically

Re: [Python-Dev] PEP 471 Final: os.scandir() merged into Python 3.5

2015-03-09 Thread Ben Hoyt
> > os.walk took 0.061s, scandir.walk took 0.012s -- 5.2x as fast > Great, looks much better. :-) Even a bit better than what I'm seeing -- possibly due to your SSD. -Ben ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Neil Girdhar
Totally agree On 9 Mar 2015 19:22, "Nick Coghlan" wrote: > > On 10 Mar 2015 06:51, "Neil Girdhar" wrote: > > > > > > > > On Mon, Mar 9, 2015 at 12:54 PM, Serhiy Storchaka > wrote: > >> > >> On 09.03.15 17:48, Neil Girdhar wrote: > >>> > >>> So you agree that the ideal solution is composition, b

Re: [Python-Dev] PEP 471 Final: os.scandir() merged into Python 3.5

2015-03-09 Thread Ryan Stuart
Hi Ben, On Mon, 9 Mar 2015 at 21:58 Ben Hoyt wrote: > Note that this benchmark is invalid for a couple of reasons. (...) > Thanks a lot for the guidance Ben, greatly appreciated. Just starting to take an interest in the development of CPython and so something like running a benchmark seemed lik

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Nick Coghlan
On 10 Mar 2015 06:51, "Neil Girdhar" wrote: > > > > On Mon, Mar 9, 2015 at 12:54 PM, Serhiy Storchaka wrote: >> >> On 09.03.15 17:48, Neil Girdhar wrote: >>> >>> So you agree that the ideal solution is composition, but you prefer >>> inheritance in order to not break code? >> >> >> Yes, I agree.

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Paul Moore
On 9 March 2015 at 23:11, Nick Coghlan wrote: > While I like the idea of offering something more "built in" in this space, > my initial inclination is to prefer extending "-m" to accept the > "module.name:function.name" format to let you invoke entry points by the > name of the target function (Po

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Donald Stufft
> On Mar 9, 2015, at 7:11 PM, Nick Coghlan wrote: > > > On 10 Mar 2015 02:37, "Donald Stufft" > wrote: > > > > > > I'm okay with this. Installing for all users is really something that > > > could be considered an advanced option rather than the default, > > > especi

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Nick Coghlan
On 10 Mar 2015 02:37, "Donald Stufft" wrote: > > > > I'm okay with this. Installing for all users is really something that could be considered an advanced option rather than the default, especially since the aim (AIUI) of the all-users install is to pretend that Python was shipped with the OS. (I'

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Neil Girdhar
On Mon, Mar 9, 2015 at 12:54 PM, Serhiy Storchaka wrote: > On 09.03.15 17:48, Neil Girdhar wrote: > >> So you agree that the ideal solution is composition, but you prefer >> inheritance in order to not break code? >> > > Yes, I agree. There is two advantages in the inheritance: larger backward >

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Neil Girdhar
It may be that the comparison that you do is between two elements that are almost always in the same cache line whereas the binary search might often incur a cache miss. On Mon, Mar 9, 2015 at 2:49 PM, nha pham wrote: > I do not know exactly, one thing I can imagine is: it turns the worst case >

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread nha pham
I do not know exactly, one thing I can imagine is: it turns the worst case of binary insertion sort to best case. With sorted array in range of 32 or 64 items, built from zero element. The new element you put into the sorted list has a high chance of being the smallest or the the highest of the sor

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Isaac Schwabacher
On 15-03-08, nha pham wrote: > > We can optimize the TimSort algorithm by optimizing its binary insertion sort. > > The current version of binary insertion sort use this idea: > > Use binary search to find a final position in sorted list for a new element > X. Then insert X to that location.

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Serhiy Storchaka
On 09.03.15 17:48, Neil Girdhar wrote: So you agree that the ideal solution is composition, but you prefer inheritance in order to not break code? Yes, I agree. There is two advantages in the inheritance: larger backward compatibility and simpler implementation. Then,I think the big questio

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Paul Moore
On 9 March 2015 at 16:35, Donald Stufft wrote: >> I'm okay with this. Installing for all users is really something that could >> be considered an advanced option rather than the default, especially since >> the aim (AIUI) of the all-users install is to pretend that Python was >> shipped with th

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Donald Stufft
> On Mar 9, 2015, at 11:37 AM, Steve Dower wrote: > > Paul Moore wrote: >> I just thought I'd give installing Python 3.5 a go on my PC, now that >> 3.5a2 has come out. I didn't get very far (see earlier message) but it >> prompted >> me to think about how I'd use it, and what habits I'd need to

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Skip Montanaro
On Mon, Mar 9, 2015 at 10:53 AM, Steven D'Aprano wrote: > On Sun, Mar 08, 2015 at 10:57:30PM -0700, Ryan Smith-Roberts wrote: >> I suspect that you will find the Python community extremely conservative >> about any changes to its sorting algorithm, given that it took thirteen >> years and some rea

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Neil Girdhar
On Mon, Mar 9, 2015 at 11:11 AM, Serhiy Storchaka wrote: > понеділок, 09-бер-2015 10:18:50 ви написали: > > On Mon, Mar 9, 2015 at 10:10 AM, Serhiy Storchaka > wrote: > > > понеділок, 09-бер-2015 09:52:01 ви написали: > > > > On Mon, Mar 9, 2015 at 2:07 AM, Serhiy Storchaka < > storch...@gmail.c

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Steven D'Aprano
On Sun, Mar 08, 2015 at 10:57:30PM -0700, Ryan Smith-Roberts wrote: > I suspect that you will find the Python community extremely conservative > about any changes to its sorting algorithm, given that it took thirteen > years and some really impressive automated verification software to find > this

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Neil Girdhar
On Mon, Mar 9, 2015 at 11:46 AM, Steven D'Aprano wrote: > On Mon, Mar 09, 2015 at 09:52:01AM -0400, Neil Girdhar wrote: > > > Here is a list of methods on > > int that should not be on IntFlags in my opinion (give or take a couple): > > > > __abs__, __add__, __delattr__, __divmod__, __float__, __

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Steven D'Aprano
On Mon, Mar 09, 2015 at 09:52:01AM -0400, Neil Girdhar wrote: > Here is a list of methods on > int that should not be on IntFlags in my opinion (give or take a couple): > > __abs__, __add__, __delattr__, __divmod__, __float__, __floor__, > __floordiv__, __index__, __lshift__, __mod__, __mul__, __

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Steve Dower
Paul Moore wrote: > I just thought I'd give installing Python 3.5 a go on my PC, now that > 3.5a2 has come out. I didn't get very far (see earlier message) but it > prompted > me to think about how I'd use it, and what habits I'd need to change. > > I'd suggest that the "what's new in 3.5" docume

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Serhiy Storchaka
понеділок, 09-бер-2015 10:18:50 ви написали: > On Mon, Mar 9, 2015 at 10:10 AM, Serhiy Storchaka wrote: > > понеділок, 09-бер-2015 09:52:01 ви написали: > > > On Mon, Mar 9, 2015 at 2:07 AM, Serhiy Storchaka > > > > And to be ideal drop-in replacement IntEnum should override such methods > > > >

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Paul Moore
On 9 March 2015 at 13:45, Nick Coghlan wrote: > I'm happy to let the folks that use Windows for development regularly > decide on the best answer from a user experience perspective, but I > think a release blocker docs issue would be a good way to go for > ensuring it gets resolved be the release

Re: [Python-Dev] Tunning binary insertion sort algorithm in Timsort.

2015-03-09 Thread Ryan Smith-Roberts
I suspect that you will find the Python community extremely conservative about any changes to its sorting algorithm, given that it took thirteen years and some really impressive automated verification software to find this bug: http://envisage-project.eu/proving-android-java-and-python-sorting-alg

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Neil Girdhar
On Mon, Mar 9, 2015 at 2:07 AM, Serhiy Storchaka wrote: > On 09.03.15 06:33, Ethan Furman wrote: > >> I guess it could boil down to: if IntEnum was not based on 'int', but >> instead had the __int__ and __index__ methods >> (plus all the other __xxx__ methods that int has), would it still be a >

Re: [Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Nick Coghlan
On 9 March 2015 at 21:19, Paul Moore wrote: > Should I raise this as a bug against the 3.5 documentation? If so, > should it be a release blocker for the final release? I'm happy to let the folks that use Windows for development regularly decide on the best answer from a user experience perspecti

Re: [Python-Dev] [RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Steve Dower
Thanks for finding this. I'm following up on the issue of anyone else is having the same issue. As an aside, it'd be great to hear if it's worked for anyone at all :) Cheers, Steve Top-posted from my Windows Phone From: Ben Hoyt Sent: ‎

Re: [Python-Dev] [RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Ben Hoyt
I'm seeing the same issue (though I also get the missing-DLL error dialog when I run python.exe). -Ben On Mon, Mar 9, 2015 at 6:20 AM, Paul Moore wrote: > On 9 March 2015 at 09:34, Larry Hastings wrote: > > On behalf of the Python development community and the Python 3.5 release > > team, I'm t

Re: [Python-Dev] PEP 471 Final: os.scandir() merged into Python 3.5

2015-03-09 Thread Ben Hoyt
Hi Ryan, > ./configure --with-pydebug && make -j7 > > I then ran ./python.exe ~/Workspace/python/scandir/benchmark.py and I got: > > Creating tree at /Users/rstuart/Workspace/python/scandir/benchtree: depth=4, > num_dirs=5, num_files=50 > Using slower ctypes version of scandir > Comparing against

[Python-Dev] Thoughts on running Python 3.5 on Windows (path, pip install --user, etc)

2015-03-09 Thread Paul Moore
I just thought I'd give installing Python 3.5 a go on my PC, now that 3.5a2 has come out. I didn't get very far (see earlier message) but it prompted me to think about how I'd use it, and what habits I'd need to change. I'd suggest that the "what's new in 3.5" document probably needs a section on

Re: [Python-Dev] [RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Paul Moore
Submitted as http://bugs.python.org/issue23619 On 9 March 2015 at 10:20, Paul Moore wrote: > On 9 March 2015 at 09:34, Larry Hastings wrote: >> On behalf of the Python development community and the Python 3.5 release >> team, I'm thrilled to announce the availability of Python 3.5.0a2. Python

Re: [Python-Dev] [RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Paul Moore
On 9 March 2015 at 09:34, Larry Hastings wrote: > On behalf of the Python development community and the Python 3.5 release > team, I'm thrilled to announce the availability of Python 3.5.0a2. Python > 3.5.0a2 is the second alpha release of Python 3.5, which will be the next > major release of Py

[Python-Dev] [RELEASED] Python 3.5.0a2 is now available

2015-03-09 Thread Larry Hastings
On behalf of the Python development community and the Python 3.5 release team, I'm thrilled to announce the availability of Python 3.5.0a2. Python 3.5.0a2 is the second alpha release of Python 3.5, which will be the next major release of Python. Python 3.5 is still under heavy development

Re: [Python-Dev] PEP 471 Final: os.scandir() merged into Python 3.5

2015-03-09 Thread Larry Hastings
On 03/07/2015 06:13 PM, Victor Stinner wrote: Hi, FYI I commited the implementation of os.scandir() written by Ben Hoyt. I hope that it will be part of Python 3.5 alpha 2 It is. //arry/ ___ Python-Dev mailing list Python-Dev@python.org https://mail

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Serhiy Storchaka
On 09.03.15 10:19, Maciej Fijalkowski wrote: Not all your examples are good. * float(x) calls __float__ (not __int__) * re.group requires __eq__ (and __hash__) * I'm unsure about OSError * the % thing at the very least works on pypy Yes, all these examples are implementation defined and can

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Antoine Pitrou
On Mon, 9 Mar 2015 15:12:44 +1100 Steven D'Aprano wrote: > > My summary is as follows: > > __int__ is used as the special method for int(), and it should coerce > the object to an integer. This may be lossy e.g. int(2.999) --> 2 or may > involve a conversion from a non-numeric type to integer

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Maciej Fijalkowski
Not all your examples are good. * float(x) calls __float__ (not __int__) * re.group requires __eq__ (and __hash__) * I'm unsure about OSError * the % thing at the very least works on pypy On Mon, Mar 9, 2015 at 8:07 AM, Serhiy Storchaka wrote: > On 09.03.15 06:33, Ethan Furman wrote: >> >> I

Re: [Python-Dev] boxing and unboxing data types

2015-03-09 Thread Serhiy Storchaka
On 09.03.15 08:12, Ethan Furman wrote: On 03/08/2015 11:07 PM, Serhiy Storchaka wrote: If you don't call isinstance(x, int) (PyLong_Check* in C). Most conversions from Python to C implicitly call __index__ or __int__, but unfortunately not all. [snip examples] Thanks, Serhiy, that's what I