tag:blogger.com,1999:blog-29632375.post1350204600005723048..comments2023-06-19T19:45:40.281-07:00Comments on vexorian's blog: Regarding c++ vs. python (in algorithm contests)Unknownnoreply@blogger.comBlogger10125tag:blogger.com,1999:blog-29632375.post-35926900221757154372015-03-11T05:26:43.025-07:002015-03-11T05:26:43.025-07:00I personally think that Python is much easier to l...I personally think that Python is much easier to learn as compared to <a href="http://cplusplusinurdu.com" rel="nofollow">c++ in urdu</a>Awais Kamranhttp://dashx.us/noreply@blogger.comtag:blogger.com,1999:blog-29632375.post-16340442119756467062015-02-26T09:05:39.725-08:002015-02-26T09:05:39.725-08:00In my view, C++ is a bit hard to learn as compare ...In my view, C++ is a bit hard to learn as compare to learning Python. <a href="http://cplusplusinurdu.com" rel="nofollow">C++ in urdu</a>Awais Kamranhttp://dashx.us/noreply@blogger.comtag:blogger.com,1999:blog-29632375.post-45514262278128125072014-10-22T23:15:21.766-07:002014-10-22T23:15:21.766-07:00The python multiple assignment you mention in `a, ...The python multiple assignment you mention in `a, b = b, a` can be used for swapping variables as shown, but it is more powerful than that. It is also used for next state assignments where state is held in multiple variables and next state is an update to those same variables based on their current state.<br /><br /><br />For example:<br /><br /><br /> colour, tag = next_colour(colour, tag), next_tag(tag)<br /><br /><br />Here the righthand side is computed from present values of both colour and tag *before* being assigned as the new values. It helps to stop those difficult to find errors when, for example, the next tag value is used to compute the next colour value which can happen if the assignment were split.<br /><br /><br />Given that the multiple assignment works for swapping variables too then there is no need for an explicit swap function. Learn the one thing and apply it in more places.Paddy3118noreply@blogger.comtag:blogger.com,1999:blog-29632375.post-737734415370797902014-02-24T15:07:56.270-08:002014-02-24T15:07:56.270-08:00Basically you can't use python in topcoder wit...Basically you can't use python in topcoder without noticing it is 10x times slower if not more :/vexoriannoreply@blogger.comtag:blogger.com,1999:blog-29632375.post-64962946403628494982014-02-24T14:58:17.828-08:002014-02-24T14:58:17.828-08:00I was expecting some performance comparison too.I was expecting some performance comparison too.Swoshnoreply@blogger.comtag:blogger.com,1999:blog-29632375.post-75879582545503468132013-09-05T07:44:26.676-07:002013-09-05T07:44:26.676-07:00I think they need 32/64 bits minimum for each valu...I think they need 32/64 bits minimum for each value, because a value needs type information and can represent an address too.<br /><br /><br />bytearray sounds good, the problem is that it turns the code lower level.vexoriannoreply@blogger.comtag:blogger.com,1999:blog-29632375.post-11270800045015825052013-09-05T07:29:01.204-07:002013-09-05T07:29:01.204-07:002500*2500 False values would be 47MB if booleans w...2500*2500 False values would be 47MB if booleans were stored in 64 bits. My guess is that they are.<br /><br />In python you can use bytearrays for True/False which appears to actually only require 1 byte per element and only 49 bytes of overhead. Still not sure how to force a list of 4 byte elements.<br /><br /># Size in MB<br />print sys.getsizeof(bytearray(2500**2)) / 2.0**20<br />5.96051120758<br /><br />#Overhead<br />print sys.getsizeof(bytearray(2500**2)) - (2500**2)<br />49JOmegaCVnoreply@blogger.comtag:blogger.com,1999:blog-29632375.post-30895156278900758702013-09-02T15:04:58.699-07:002013-09-02T15:04:58.699-07:00That's because I tend to forget about a SRM...That's because I tend to forget about a SRM's problems the moment I finish the editorial.vexoriannoreply@blogger.comtag:blogger.com,1999:blog-29632375.post-66189390708563118772013-09-02T14:58:08.794-07:002013-09-02T14:58:08.794-07:00Nice post!
You say that you haven't found a ...Nice post!<br /><br /><br />You say that you haven't found a d1-hard solvable in python, but for SRM586's hard you claimed your Python code works in time :)Eldarnoreply@blogger.comtag:blogger.com,1999:blog-29632375.post-79205861153215343302013-08-31T06:52:51.222-07:002013-08-31T06:52:51.222-07:00In C++11 swap uses std::move which is much faster ...In C++11 swap uses std::move which is much faster for STL containers and other classes which have move constructors. So now that looks like<br /><br /><br />T c{std::move(a)};<br />a = std::move(b);<br />b = std::move(c);Oleksandr Sochkanoreply@blogger.com