You probably know how to rewrite a for loop such as:
If you have a variable with a large memory footprint, you can force garbage collection using the gc Garbage Collector module:
You can check for class inheritance relationships with the issubclass() built-in:
if mystring and mystring.strip(): print "not null and not empty string" else: print "null or empty string"
In Spark >= 1.5 you can use the size function to calculate the length of a column: