On 23/06/16 19:00, Bharath Swaminathan wrote: > Can I run my python code in multiple processors? I have a dual core...
Your OS may run your python code on multiple processors but it's not something you can easily control in Python. Remember that your computer probably has hundreds of processes running at any one time and your python program(s) will only be a part of the total load. The OS schedules the jobs to run on whichever processor is available at any given time - it may well use different processors for the same process during the lifetime of that process. Now, if what you really want to know is whether the OS can split a single Python process over multiple CPU cores in parallel, that's a much more complex question and I think the current answer is probably not. (But others on this list know a lot more about that kind of thing than I do!) But it depends on the exact version of Python you are running and probably which OS you are using too. In my experience trying to guess how the OS will schedule your jobs is an exercise in frustration. Let the OS do its thing and only worry about those kinds of optimisation once you have proved it is really an issue (by measurement). -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor