Generic question regarding Python-code.  How can I most effectively locate the worst parts of my Python-code with respect to memory usage?  See e.g. this small example  def my_func():     a = [1] * (12 ** 4)     return a  def my_func2():     b = [2] * (10 ** 7)     return b  if __name__ == '__main__':     a1 = my_func()     a2 = my_func2()   How can I in an automated way tell that a2 is much larger that a1 in size? And how can I - still automated - root this back towards my_func1() and my_func2()?  For C/C++ code I would use valgrind --tool=massif, which can directly locate the heavy-weights regarding memory usage - but for Python I need your help.  appears to give some of the answer, but not nearly as good as massif does for C/C++.
I want to know the memory usage of my Python application and specifically want to know what code blocks/portions or objects are consuming most memory. Google search shows a commercial one is  (Windows only).  And open source ones are  and .  I haven't tried anyone, so I wanted to know which one is the best considering:   Gives most details. I have to do least or no changes to my code.
Do images need a border around them? What does "it" refer to in "it's raining"? How do you use Excel server-side? A client wants to "Web-enable" a spreadsheet calculation -- the user to specify the values of certain cells, then show them the resulting values in other cells.  (They do NOT want to show the user a "spreadsheet-like" interface. This is not a UI question.)  They have a huge spreadsheet with lots of calculations over many, many sheets.  But, in the end, only two things matter -- (1) you put numbers in a couple cells on one sheet, and (2) you get corresponding numbers off a couple cells in another sheet.  The rest of it is a black box.  I want to present a UI to the user to enter the numbers they want, then I'd like to programatically open the Excel file, set the numbers, tell it to re-calc, and read the result out.  Is this possible/advisable?  Is there a commercial component that makes this easier?  Are their pitfalls I'm not considering?  (I know I can use Office Automation to do this, but I know it's not recommended to do that server-side, since it tries to run in the context of a user, etc.)  A lot of people are saying I need to recreate the formulas in code.  However, this would be staggeringly complex. Question:   Answer:   The question was closed at 11:57:57 (according to the hover-over-"x-mins-ago" bar) and the answer was posted at 12:16:35. It's a fairly lengthy answer, so it's possible that it was started to be written before it was closed but I swear I've started to answer a question then I got a banner along the top saying "this question has been closed" and the answer was no longer post-able. I checked this  but didn't fully understand it.   I know that the volume of a right circular cone is $V = \frac{1}{3}\pi x^2h$  I know that I must take the first derivative and set it equal to zero, which will find the maximum.   My problem is how to deal with the variable $h$, the height?   How can I rewrite that in terms of $x$ or $r$.      I have tried to implicitly differentiate this equation, but that wasn't helpful for me. Direction of Friction on two stacked boxes Understanding etoolbox \ifdefempty and \ifdefvoid I am trying to understand the  \ifdefempty and \ifdefvoid macros. The documentation says that \ifdefempty     Expands to true if the control sequence is defined and is a   parameterless macro whose replacement text is empty, and to false   otherwise.   Similarly \ifdefvoid     Expands to true if the control sequence is undefined, if is a macro   whose meaning is \relax, or a parameterless macro whose replacement   text is empty, and to false otherwise.   From these descriptions I thought that \def\myempty{}, \def\myrelax{\relax}, and \def\myemptyempty{\myempty} would all be both "empty" and "void", but \def\myempty{} is the only one that is either "empty" or "void". What am I missing?  \documentclass{minimal} \usepackage{etoolbox}  \begin{document}  \def\myempty{} \def\myrelax{\relax} \def\myemptyempty{\myempty}   \ifdefempty{\myempty}{Empty}{Not empty}  \ifdefempty{\myrelax}{Empty}{Not empty}  \ifdefempty{\myemptyempty}{Empty}{Not empty}  \ifdefvoid{\myempty}{Void}{Not void}  \ifdefvoid{\myrelax}{Void}{Not void}  \ifdefvoid{\myemptyempty}{Void}{Not void}  \end{document} I've got the following question:  $A = \{\sqrt{n} - \left\lfloor\sqrt{n}\right\rfloor : n \in \mathbb{N}\}$  Find inf A, sup A    inf A is no big deal, but I have a hard time proving sup A is 1  I've tried to prove that: $\sqrt{n^2 - 1} -\left\lfloor\sqrt{n^2-1}\right\rfloor &gt; \sqrt{n} -\left\lfloor\sqrt{n}\right\rfloor $  but couldn't find a way to do that I'm on a Mac and the cp and mv commands are killing me due to them copying the contents of a directory if a trailing slash is present. It has bitten me more than once when I use tab completion to specify the directory I want to copy.  I have noticed zsh has a neat feature that removes the trailing slash if it's not needed after a space or enter key is pressed. Is there any way to have bash mimic this behavior? Why does the version of Java verified by Oracle differ from the version shown at the command line? Didn't understand relationship 'AccountContactRelation' in FROM part of query call I'm getting the following error message:     System.QueryException: Didn't understand relationship 'AccountContactRelation' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.   Select Email, Id, (Select ContactId, AccountId From AccountContactRelation) From Contact  In AccountContactRelation object there are two lookup fields for Account and for Contact.  Please advise how to avoid such error message? How can I recover a deleted file on Android? I just deleted a file on my Nexus S that I really need back. (It was actually part of an app using a sqlite database that did a drop table when upgrading to a new version.)  Presumably I need to root the phone first (which I hear is easy on Nexus phones) but am I in a catch-22 here? Namely, does rooting the phone mean wiping/overwriting the partition where the data lives?  If not, what do you recommend for data recovery tools? Presumably the file was just unlinked and not actively overwritten (per usual when "deleting" a file) so technically the data must be there... Will acceleration rate of expansion of space become faster than speed of light? Are there any command to see how processes are working? I'm very new to Ubuntu. If I do this sort of command say:  cp file1 file2   The shell creates a child process and that child process will call cp, which in turn call exec system call of operating system.   Are there any command to visualize this process from my terminal? Let $q: \mathbb{N} \to \mathbb{Q}$ be a bijection and denote the image of $k \in \mathbb{N}$ by $q_k$.  Let $f: \mathbb{R} \to (0,1)$, $$ f(x) = \underset{q_k \leq x}{\sum_{k \in \mathbb{N}}} 2^{-k} $$  Show that:  1) $f$ is strictly increasing  2) $f$ is continuous at $x$ iff $x \in \mathbb{R} \setminus \mathbb{Q}$.  My work:  Let $x, y \in \mathbb{R}$, $x &lt; y$. Then there exists $q_n \in \mathbb{Q}$ s.t. $x &lt; q_n &lt; y$. Now $$ f(x) = \underset{q_k \leq x}{\sum_{k \in \mathbb{N}}} 2^{-k} &lt; \underset{q_k \leq x}{\sum_{k \in \mathbb{N}}} 2^{-k} + 2^{-n} \leq \underset{q_k \leq y}{\sum_{k \in \mathbb{N}}} 2^{-n} = f(y) $$ so $f$ is strictly increasing.  I think my proof of 1) is ok, but how can I prove 2)? ID for Contact portion of Person Account Is it possible to get the ID of a Contact which is part of a Person Account?  I have a custom object which has a custom field referencing the Person Account, though it seems to be referencing the Contact directly. I have created a button which I am using to pass the ID into a Visualforce Page.  With the Insert Field drop-down on the create/edit button page I can put in {!Account.Id} or {!Contact.Id} but neither of these work. The Account ID is placed in the URL but is not the correct ID and the Contact ID is blank, which I assume is because the button is on a Person Account page and not a Contact Page. How do I run a GUI app via SSH? Get bytes from std::string in C++ I'm working in a C++ unmanaged project.  I need to know how can I take a string like this "some data to encrypt" and get a byte[] array which I'm gonna use as the source for Encrypt.  In C# I do    for (int i = 0; i &lt; text.Length; i++)     buffer[i] = (byte)text[i];   What I need to know is how to do the same but using unmanaged C++.  Thanks! Find weak form of linear transport equation I am stuck on the following problem that says:       a) Find a weak formulation for the partial differential equation $${\partial u\over\partial t\ }+ c{\partial u \over \partial x\ }=0$$    b) Show that $u=f(x-ct)$ is a generalized solution of $${\partial u\over\partial t\ }+ c{\partial u \over \partial x\ }=0$$ for any distribution $f$    My Attempt:   I know that in order to find a weak form of a pde, we need to multiply it by a test function, then integrate it. Also, to find a generalized solution, we need to find a weak solution and just multiply it by the Heaviside function.  Let's take any test function $\phi $, then we have (integrating by parts second part of the integral) $$\int_{\Omega } ( {\partial u\over\partial t\ }+ c{\partial u \over \partial x\ })*\phi(x) dx= \int_{\Omega } {\partial u\over \partial t}\phi(x) dx - c\int_{\Omega } u(x,t)\phi'(x)dx$$ where $\phi $ vanishes at boundaries. So, is it the final form or can we proceed further? And how am I supposed to find a generalized solution?  Can someone help me out? Thanks in advance for your time. How to get from Nice to Monaco by public transport? What's the simplest and cheapest way to get from central Nice, France to Monaco by public transportation?