[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-02-08 Thread Andy Lester
Andy Lester added the comment: I'm closing this as it seems there's not much interest in this. -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-09 Thread Andy Lester
Andy Lester added the comment: Re: branch prediction. The branch if (c1>=37 && c1<=126) could just as easily be if (c1>=0 && c1<=126) with no other changes to the code. It could be just if (c1<=126) if c1 wasn't signed. As far as branch prediction, we could make it somethin

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-09 Thread Andy Lester
Andy Lester added the comment: Yes, I ran it multiple times on my 2013 Macbook Pro and got ~10% speedup. I also ran it on my Linux VM (that I only use for development) and got a speedup but less so. The code I used to run the tests is at: https://github.com/petdance/cpython/blob/Issue39150

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The difference around 10% looks very strange. Tokenizing is just one of parts of the compiler, and unlikely it is a narrow way. There are input/output, many memory allocations, encoding and decoding, many iterations and recursions. Are you sure that you ru

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-09 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I will take a look and try to reproduce the benchmarks result you mentioned, but if under PGO there is no substantial performance increase is much less appealing as the lookup table code is less clear and maintainable than the simple switch. Also you

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2020-01-08 Thread Andy Lester
Andy Lester added the comment: I tried out some experimenting with the lookup table vs. the switch statement. The relevant diff (not including the patches to the code generator) is: --- Parser/token.c +++ Parser/token.c @@ -77,31 +77,36 @@ int PyToken_OneChar(int c1) { -switch (c1) {

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2019-12-28 Thread Andy Lester
Andy Lester added the comment: Thank you. I appreciate the pointer. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2019-12-28 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > PyToken_OneChar in Parser/token.c is autogenerated. I suspect it may be > faster and smaller if it were a lookup into a static table of ops rather than > a switch statement. Check to see if it is. I suspect that it will be marginally faster (becau

[issue39150] See if PyToken_OneChar would be faster as a lookup table

2019-12-28 Thread Andy Lester
New submission from Andy Lester : PyToken_OneChar in Parser/token.c is autogenerated. I suspect it may be faster and smaller if it were a lookup into a static table of ops rather than a switch statement. Check to see if it is. -- components: Interpreter Core messages: 358975 nosy: p