how to handle cpu cache in python ( or fastest way to call a function once)

2015-08-22 Thread Yuzhi Xu
I find out that python's VM seems to be very unfriendly with CPU-Cache. see: http://stackoverflow.com/questions/32163585/how-to-handle-cpu-cache-in-python-or-fastest-way-to-call-a-function-once http://stackoverflow.com/questions/32153178/python-functionor-a-code-block-runs-much-slower-with-a-tim

Qestion

2015-08-22 Thread ali ranjbar
hi dear friend I have python version 2.4.3 Which version of PIL is appropriate for me and how can I add it to my systems? Regards -- https://mail.python.org/mailman/listinfo/python-list

Re: Bug!

2015-08-22 Thread Simon Ward
On 23 August 2015 00:06:44 BST, Chris Angelico wrote: >Precisely. Every time you support multiple versions of some >dependency, you have to test your code on all of them, and in the >common case (new features added in newer versions), you have to target >the oldest and weakest version. Just don

Re: Sandboxing Python

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 3:17 PM, Christian Gollwitzer wrote: > Would it be that difficult to get the same for Python? On the C side, the > interpreter is a structure and does not use global variables (as opposed to > CPython), therefore it is easy to create more than one interpreter in a > single

Re: Sandboxing Python

2015-08-22 Thread Christian Gollwitzer
Am 23.08.15 um 02:04 schrieb Chris Angelico: import os eval("os.system('rm -rf /')", {"__builtins__":None}) Traceback (most recent call last): File "", line 1, in eval("os.system('rm -rf /')", {"__builtins__":None}) File "", line 1, in TypeError: 'NoneType' object is not subscript

Re: Sandboxing Python

2015-08-22 Thread Laura Creighton
Ned Batchelder has researched this one quite a bit, see: see: http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html http://nedbatchelder.com/blog/201302/looking_for_python_3_builtins.html http://nedbatchelder.com/blog/201302/finding_python_3_builtins.html Laura -- https://mail.pytho

Re: Bug!

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 11:22 AM, Simon Ward wrote: > > > On 23 August 2015 00:06:44 BST, Chris Angelico wrote: >>Precisely. Every time you support multiple versions of some >>dependency, you have to test your code on all of them, and in the >>common case (new features added in newer versions), y

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 10:51 AM, Cecil Westerhof wrote: > How do I see if there is an open socket? Depends on your OS. On Linux, I can poke around in /proc or with commands like netstat and/or lsof. It may be easier to separate client and server across two computers, which would force the socket

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Sunday 23 Aug 2015 01:13 CEST, Chris Angelico wrote: > On Sun, Aug 23, 2015 at 7:06 AM, Cecil Westerhof wrote: >> I have included the output as attachment. It is clear that bottle >> is not the problem: fetching all the data takes at most 0.017 >> seconds. >> > > Something to consider: You cou

Re: Sandboxing Python

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 9:52 AM, Mark Lawrence wrote: > On 23/08/2015 00:44, Chris Angelico wrote: >> >> On Sun, Aug 23, 2015 at 9:25 AM, Mark Lawrence >> wrote: >>> >>> I was always led to believe that the subject was a difficult thing to do, >>> but here >>> >>> https://www.reddit.com/r/learnpy

Re: Sandboxing Python

2015-08-22 Thread Mark Lawrence
On 23/08/2015 00:44, Chris Angelico wrote: On Sun, Aug 23, 2015 at 9:25 AM, Mark Lawrence wrote: I was always led to believe that the subject was a difficult thing to do, but here https://www.reddit.com/r/learnpython/comments/3huz4x/how_to_do_math_inside_raw_input/ is a safe solution in only 23

Re: Sandboxing Python

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 9:25 AM, Mark Lawrence wrote: > I was always led to believe that the subject was a difficult thing to do, > but here > https://www.reddit.com/r/learnpython/comments/3huz4x/how_to_do_math_inside_raw_input/ > is a safe solution in only 23 characters, or are there any discerna

Sandboxing Python

2015-08-22 Thread Mark Lawrence
I was always led to believe that the subject was a difficult thing to do, but here https://www.reddit.com/r/learnpython/comments/3huz4x/how_to_do_math_inside_raw_input/ is a safe solution in only 23 characters, or are there any discernable flaws in it? -- My fellow Pythonistas, ask not what o

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 7:06 AM, Cecil Westerhof wrote: > I have included the output as attachment. It is clear that bottle is > not the problem: fetching all the data takes at most 0.017 seconds. > Something to consider: You could be running into some weird interaction of caches. Try blowing you

Re: Bug!

2015-08-22 Thread Chris Angelico
On Sun, Aug 23, 2015 at 3:08 AM, Tim Golden wrote: > On 22/08/2015 02:02, Chris Angelico wrote: >> >> The security concerns of XP aren't Python's problem, and Python isn't >> in the business of twisting people's arms to make them upgrade just >> for the sake of upgrading. However, every new versio

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Saturday 22 Aug 2015 20:03 CEST, Cecil Westerhof wrote: > On Saturday 22 Aug 2015 17:33 CEST, Michael Torrie wrote: > >> On 08/22/2015 05:37 AM, Cecil Westerhof wrote: I don't know. Is it bottle, or the browser, or something completely different that eats the extra time? >>> >>> I rea

Best strategy for testing class and subclasses in pytest?

2015-08-22 Thread C.D. Reimer
Greetings, I'm writing a chess engine to learn about Python classes and inheritance, and using pytest for the unit test. I've created a Piece class, which has 99% of the functionality for a chess piece, and subclass the other pieces -- Bishop, King, Knight, Pawn, Queen, Rook -- that will impl

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Saturday 22 Aug 2015 17:33 CEST, Michael Torrie wrote: > On 08/22/2015 05:37 AM, Cecil Westerhof wrote: >>> I don't know. Is it bottle, or the browser, or something >>> completely different that eats the extra time? >> >> I really do not know. I suspect bottle, but I am new to this, so I >> val

Re: Bug!

2015-08-22 Thread Tim Golden
On 22/08/2015 02:02, Chris Angelico wrote: The security concerns of XP aren't Python's problem, and Python isn't in the business of twisting people's arms to make them upgrade just for the sake of upgrading. However, every new version of Windows introduces new APIs and features, so maintaining su

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Rustom Mody
On Saturday, August 22, 2015 at 9:03:52 PM UTC+5:30, Michael Torrie wrote: > While it's true this particular problem is possibly beyond the scope of > this python list (and may not be python-related at all), it's too bad a > couple of people have taken the time to reply to your queries to simply >

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Michael Torrie
On 08/22/2015 05:37 AM, Cecil Westerhof wrote: >> I don't know. Is it bottle, or the browser, or something completely >> different that eats the extra time? > > I really do not know. I suspect bottle, but I am new to this, so I > value the suspicion of someone who has more experience more. :-D T

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Christian Gollwitzer
Am 22.08.15 um 15:51 schrieb Johannes Bauer: On 22.08.2015 15:09, Cecil Westerhof wrote: So let me get your story straight: I wish you really meant that. I really do, did I get it wrong at all? I really don't think that I did. Probably yes. You should take a look at the OP again and compa

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Johannes Bauer
On 22.08.2015 15:09, Cecil Westerhof wrote: >> So let me get your story straight: > > I wish you really meant that. I really do, did I get it wrong at all? I really don't think that I did. > Also: take a course in reading. Maybe you, oh very wise Senior Software Engineer, should take a course

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Saturday 22 Aug 2015 14:09 CEST, Johannes Bauer wrote: > On 22.08.2015 13:28, Cecil Westerhof wrote: > >> If you would have taken a little more time you would have seen that >> there where 20 seconds between both logs. I am fast, but not that >> fast. It is exactly the same code. I suppose it h

Re: SQLite3 and web server

2015-08-22 Thread Peter Otten
Cecil Westerhof wrote: > On Saturday 22 Aug 2015 09:51 CEST, Peter Otten wrote: > >> Cecil Westerhof wrote: >> >>> Thanks. I made a first try: >>> https://github.com/CecilWesterhof/PublishedPhotos >>> >>> The thing I do not like is that all my static files have to be put >>> in /static/, but I th

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Johannes Bauer
On 22.08.2015 13:28, Cecil Westerhof wrote: > If you would have taken a little more time you would have seen that > there where 20 seconds between both logs. I am fast, but not that > fast. It is exactly the same code. I suppose it has to do something > with bottle. Something I use since yesterday

Re: SQLite3 and web server

2015-08-22 Thread Cecil Westerhof
On Friday 21 Aug 2015 16:57 CEST, Michael Torrie wrote: > On 08/21/2015 08:19 AM, Michael Torrie wrote: >> But of course you can use straight CGI with Apache too. Probably >> this is the easiest way for you to get started. Don't try to run >> your own http server. That's just a waste of time and e

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Saturday 22 Aug 2015 09:49 CEST, Peter Otten wrote: > Cecil Westerhof wrote: > >> I created a simple application with bottle: >> https://github.com/CecilWesterhof/PublishedPhotos >> >> But sometimes it needs a lot of time. For example: 127.0.0.1 - - >> [21/Aug/2015 23:16:40] "GET / HTTP/1.1" 30

Re: SQLite3 and web server

2015-08-22 Thread Cecil Westerhof
On Saturday 22 Aug 2015 09:51 CEST, Peter Otten wrote: > Cecil Westerhof wrote: > >> Thanks. I made a first try: >> https://github.com/CecilWesterhof/PublishedPhotos >> >> The thing I do not like is that all my static files have to be put >> in /static/, but I think I can life with it. > > Is that

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Friday 21 Aug 2015 23:55 CEST, gst wrote: > What if you try with all the SQLite code commented ? I do not think that is the problem. First of all I do not think receiving 25 records takes 6 seconds. Secondly the first part is: 127.0.0.1 - - [21/Aug/2015 23:16:40] "GET / HTTP/1.1" 304 0 127.0.

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Cecil Westerhof
On Saturday 22 Aug 2015 11:41 CEST, Johannes Bauer wrote: > On 21.08.2015 23:22, Cecil Westerhof wrote: > >> Just before everything was done in a second: > > Since you're on GitHub, why don't you git bisect and find out where > you screwed up instead of trying to get people to remotely debug and >

Re: Every character of a string becomes a binding

2015-08-22 Thread Johannes Bauer
On 21.08.2015 19:04, Cecil Westerhof wrote: >> Because the execute method expects the bindings to be passed as a >> sequence, > > Yeah, I found that. I solved it a little differently: > urls = c.execute('SELECT URL FROM links WHERE URL = ?', [url]).fetchall() You continuously ask more than am

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Johannes Bauer
On 21.08.2015 23:22, Cecil Westerhof wrote: > Just before everything was done in a second: Since you're on GitHub, why don't you git bisect and find out where you screwed up instead of trying to get people to remotely debug and profile your broken code? Cheers, Johannes -- >> Wo hattest Du das

Re: SQLite3 and web server

2015-08-22 Thread Peter Otten
Cecil Westerhof wrote: > Thanks. I made a first try: > https://github.com/CecilWesterhof/PublishedPhotos > > The thing I do not like is that all my static files have to be put in > /static/, but I think I can life with it. Is that really required by bottle? Where would you like to put the files?

Re: Sometimes bottle takes a lot of time

2015-08-22 Thread Peter Otten
Cecil Westerhof wrote: > I created a simple application with bottle: > https://github.com/CecilWesterhof/PublishedPhotos > > But sometimes it needs a lot of time. For example: > 127.0.0.1 - - [21/Aug/2015 23:16:40] "GET / HTTP/1.1" 304 0 > 127.0.0.1 - - [21/Aug/2015 23:16:40] "GET /static/css