Halaman

    Social Items

 

Clear Memory in Python

  1. 1. Clear Memory in Python Using the gc.collect() Method
  2. 2. Clear Memory in Python Using the del Statement

This tutorial will look into the methods to free or clear memory in Python during the program execution. When a program has to deal with large files, process a large amount of data, or keep the data in the memory. In these types of scenarios, the program can often run out of memory.

To prevent the program from running out of memory, we have to free or clear the memory by clearing the variable or data, which is no more needed in the program. We can clear the memory in Python using the following methods.

Clear Memory in Python Using the gc.collect() Method

The gc.collect(generation=2) method is used to clear or release the unreferenced memory in Python. The unreferenced memory is the memory that is inaccessible and can not be used. The optional argument generation is an integer whose value ranges from 0 to 2. It specifies the generation of the objects to collect using the gc.collect() method.

In Python, the short-lived objects are stored in generation 0 and objects with a longer lifetime are stored in generation 1 or 2. The list maintained by the garbage collector is cleared whenever the gc.collect() with default generation value equal to 2 is called.

The gc.collect() method can help decrease memory usage and clear the unreferenced memory during the program execution. It can prevent the program from running out of memory and crashing by clearing the memory’s inaccessible data.

Clear Memory in Python Using the del Statement

Along with the gc.collect() method, the del statement can be quite useful to clear memory during Python’s program execution. The del statement is used to delete the variable in Python. We can first delete the variable like some large list, or array, etc., about which we are sure that are no more required by the program.

The below example code demonstrates how to use the del statement to delete the variable.

import numpy as np

a= np.array([1,2,3])
del a

Suppose we try to use or access the variable after deleting it. In that case, the program will return the NameError exception as the variable we are trying to access no more exists in the variable namespace.

Example code:

import numpy as np

a= np.array([1,2,3])
del a
print(a)

Output:

NameError: name 'a' is not defined

The del statement removes the variable from the namespace, but it does not necessarily clear it from memory. Therefore, after deleting the variable using the del statement, we can use the gc.collect() method to clear the variable from memory.

The below example code demonstrates how to use the del statement with the gc.collect() method to clear the memory in Python.

import numpy as np
import gc

a = np.array([1,2,3])
del a
gc.collect()

Diagnosing and Fixing Memory Leaks in Python



From being named People’s “Sexiest Man Alive” to earning three consecutive Oscar nominations, Bradley Cooper has had quite an interesting career. His big blue eyes have always won over the hearts of swooning fans, but Cooper had to pay his dues for many years to lead up to the critical acclaim he has earned today. With roles such as the distant war hero Chris Kyle in the controversial American Sniper to a struggling bipolar man just released from a psychiatric hospital in Silver Linings Playbook, Cooper has shown a range of acting skills in the last few years that arguably had not been expected in the past.


The 40-year-old actor had his up and downs, starring in minor roles of a diverse assortment of characters. Living past the pretty-boy persona can be a difficult feat but despite Cooper’s own personal struggles, he has far surpassed that, showing the world that he is a capable and talented actor. His days of being the beau to some famous actress are over, and now he is front and center. So here are 10 awesome things you probably never knew about Bradley Cooper.

He Auditioned For Green Lantern
Though talks of Bradley Cooper in the running for an upcoming Green Lantern role are currently traveling through the internet, this wouldn’t be the first time the actor auditioned for the part. Back in 2009, Cooper was a frontrunner against Ryan Reynolds for the titular role in Green Lantern. He told Conan O’Brien on The Tonight Show (via MTV) that during his audition he couldn’t help but imitate Christian Bale’s Batman:
I couldn't not do Christian Bale's Batman when I was doing the audition. I don't know what it was! I put a mask on and the director was like, 'Okay Bradley, be regular and talk.' And I was like, 'Yeah, got it... [in a deep, gravely Batman voice] listen, Sally, we're going to have to take your family away if you don't listen to me!' By the way, that's the worst Batman [impression] ever. I apologize.


He Gained 40 Pounds For His American Sniper Role
For his role as Chris Kyle, Bradley Cooper put on about 40 pounds of pure muscle to resemble the war hero. He had two workouts a day of two hours each and instead of having a year, Cooper only had three months of prep before shooting started. Cooper told Vanity Fair that during his workouts he listened to the exact same playlist that Chris Kyle had when he worked out in between shifts as a navy SEAL. He ate 5,000 calories a day and by the end of his time working out he was able to deadlift 415 pounds for five sets of eight reps. He even learned how to hold and shoot the various weapons Kyle used from former navy Seals who served with him. He kept in character the entire shoot.

He Missed Graduation To Be In Wet Hot American Summer
While Bradley Cooper was finishing up his MFA at The New School, he was beginning his acting career. He had taken some small guest role appearances on TV shows and even served as a presenter for a travel-adventure series called Globe Trekker But his film debut came in the cult classic comedy, Wet Hot American Summer. The problem was that filming happened to be right around the time Cooper graduated. He joked with GQ saying he missed his graduation to “get fucked in the ass by Michael Ian Black”.

He Asked J.J. Abrams To Write Him Off Alias
Bradley Cooper asked J.J. Abrams to write him off of Alias because he thought that he was going to fire him anyway. He explained in his GQ interview that his part grew less substantial as the show progressed and it nearly ended his career. Because of his aggravation, he asked to be written off despite having no future jobs lined up, and within a couple weeks he ended up tearing his Achilles while playing basketball and spend the next year on his couch debating whether or not to quit acting altogether.

His Most Difficult Role Was In The Hangover
For an actor who has played a bipolar man, an experienced war hero, and an FBI agent, it’s hard to believe that Bradley Cooper’s found his most difficult role to be that of a sunglass-rocking teacher named Phil. Cooper told The Guardian that his role in the box office hit The Hangover was actually his most difficult yet. He said:
That guy is so different from me. I'm always amazed by it, actually. When I look at that character on screen, I don't see me at all.


James Lipton Knew He’d Be Famous
James Lipton, host of Inside the Actors Studio predicted Bradley Cooper’s stardom. Not only was he sitting in on the auditions during Cooper’s application to the masters program, but he was particularly drawn to Cooper’s performance. According to Vanity Fair, after Cooper’s master’s thesis performance (which he performed scenes from The Elephant Man) Cooper’s mother asked Lipton what he thought and Lipton responded:
He’s going to go all the way. I never predicted that for any other student.


He Was In Sex And The City And Learned To Drive Stick
Bradley Cooper’s first TV appearance when he moved to New York was in an early episode of Sex and the City where he played one of Sarah Jessica Parker’s hunky love interests. Cooper told The Guardian that upon landing the role there was one very specific thing that it required, “no tongues”. In a Backstage interview, he divulged that he had a big problem with his newly earned role though, in that he didn’t know how to drive stick shift. He quickly went to a driving school in Manhattan, but it didn’t work out too well, and a stand-in had to drive instead.

He Knew He Wanted To Be An Actor After Seeing Elephant Man
Bradley Cooper knew he wanted to be an actor after seeing David Lynch’s The Elephant Man when he was 12 years old. He told Vanity Fair that he was sitting on the red couch in his living room sobbing and aware of the dignity and humanity of John Merrick, even though Cooper himself was still so young. And Cooper actually just recently revived the role of John Merrick in the Broadway revival of the Bernard Pomerance play The Elephant Man.

He Was A Doorman At Morgans Hotel When He First Moved To New York
When he moved New York to study acting at the New School, Bradley Cooper worked nights at the Morgans Hotel in Manhattan. He told Esquire that every night he carried had to carry a bunch matches and as a new guest was welcomed he would have to relight all the votive candles and scurry to the door for them. Many celebrities stayed there as well, and one night he welcomed Leonardo DiCaprio who was hot off his Titanic role, and all Bradley could think about was how different the two actors were.

He’s Super Smart
Not only is Bradley Cooper fluent in French (which has blown up the internet), but he also graduated with honors from Georgetown with an English degree. He told GQ he wrote his thesis on Nabokov's Lolita and he didn’t participate in much drama in high school or at Georgetown but was more of an athlete up until he went for his MFA. Cooper somewhat randomly applied for his master’s at the Actors Studio Drama School in New York almost as a joke but ended up getting in. Even during his acting career he has contemplated going back to school to get his Ph.D. in English and teaching literature.

Thanks & Cheers

Bradley Cooper: 10 Awesome Things You Probably Never Knew

 Dogecoin, ethereum, and bitcoin were all trading lower on the day


Bitcoin sold off sharply Wednesday. The slump represented an acceleration of a downtrend in the world’s No. 1 crypto that had begun over the past 10 days or so, investors and industry specialists told MarketWatch.

At last check, bitcoin prices BTCUSD, 3.11% were changing hands at $38,732,56 on CoinDesk, which is actually a remarkable feat since it touched a session low of $30,201.96 before bouncing back.

Prices of Ether ETHUSD, 5.74% on the ethereum blockchain were off 22% at $2,608.84 after touching an intraday nadir at 1,902.08, and dogecoin DOGEUSD, 4.82% was off 25%, changing hands at 35.8 cents.

When bitcoin sneezes the rest of the crypto complex catches a cold because the dominant digital asset has increasingly become a gauge of sentiment not just in nonconventional markets but as a measure of risk appetite more broadly.

The stock market also saw substantial selling on the day, which abated somewhat by the closing bell. The Dow Jones Industrial Average DJIA, -0.48%, the S&P 500 index SPX, -0.29%, and the Nasdaq Composite Index COMP, -0.03% suffered a third straight day of losses.

Why is bitcoin crashing?

Don’t call it a crash. Bitcoin is falling, but it's an asset known for volatile periods.

Its current slump isn’t pegged to one single event or piece of news but was instead being blamed on fear, uncertainty, and doubt, or FUD, in the parlance of crypto traders. Fear, at least partly, centered on China’s digital-asset policy. The People’s Republic was reportedly cracking down on the use of digital assets. For veteran crypto investors, such reports aren’t new.

Meanwhile, bearish tweets from crypto enthusiast Elon Musk were also credited with tanking the crypto complex. Musk said earlier this month that he would no longer allow bitcoin to be used for payment at electric-vehicle maker Tesla TSLA, -2.49% until the crypto becomes more environmentally friendly.

Musk had been one of the key reasons that crypto broadly had been on an uptrend, with his tweets on meme coin dogecoin and bitcoin supporting an uptrend in those assets.

Separately, analysts at JPMorgan Chase & Co. JPM, -0.76%, including Nikolaos Panigirtzoglou, make the case that investors in bitcoin were shifting to gold futures GC00, -0.43%, which coincidentally has been seeing steady climbs in recent trade.

“Institutional investors appear to be shifting away from bitcoin and back into traditional gold,” they wrote.

Market participants told MarketWatch that Wednesday’s losses also were being amplified by the use of leverage which was forcing margin calls at some crypto trading platforms.

Complicating matters, some crypto trading platforms, including Coinbase Global COIN, -5.94%, experienced outages that appeared to help put further pressure on prices.

A spokeswoman for Coinbase said that the company’s trading problems have since been resolved.

Will bitcoin prices recover?

Bitcoin and crypto are inherently volatile.

Bespoke Investment Group says that the average drawdown from a record high is close to 50%, and on 69% of all trading days over the past decade, bitcoin has been down more than 40% from its record high.

That said, bullish investors are advocating that long-term investors stay the course or review their original investment thesis before dumping crypto holdings.

Over the course of the past 11 years, bitcoin has seen more than 750 instances where prices saw a daily change of 5% or greater, more than 230 instances in which it swung by at least 10%, and nearly 50 times that it has moved by at least 20%, according to Dow Jones Market Data.

DOW JONES MARKET DATA

“Correction in the cryptocurrency market is a common phenomenon. It doesn’t mean, however, that a bear market is underway,” wrote Konstantin Boyko-Romanovsky, CEO and founder of All nodes, in emailed comments.

To be sure, past performance is no guarantee of future results but that is what bullish investors tend to hang their hats on when they advocate for long-term ownership of bitcoin and its ilk.


Why is crypto crashing? Will bitcoin prices ever recover? Here’s what traders and investors say

 


As a recent grad, you’ve probably had at least a couple of experience working in a “real world” office. But the question is, what changes when you’re a full-time employee and not just a summer or semester-long intern?

Lucky for you, we scoured the web for the advice you need to know as you take your first steps into the big, bad workforce.

  1. College won’t teach you about these seven things you need to know about entering the workforce. (Mashable)
  2. Understanding that grammar counts is just one of the many pieces of unconventional career advice you should learn before you start your first job. (Forbes)
  3. Sheryl Sandberg has some great words of wisdom for recent grads just starting to look at the job market. First things first? Banish self-doubt. (Entrepreneur)
  4. Are you really all that prepared for the workforce? Studies show you may not be. (Slate)
  5. Soft skills? Yeah, those are really, really important when you’re starting off your career. (Fox Business)
  6. Forget what you need to do when starting out; here’s what not to do. (The New York Times)
  7. A lot of times new grads forget that there is in fact a transition period between college and the real world. (Quintessential Careers)
  8. Once you get settled in, there are nine things you should do during the first week of your job. (Business Insider)
See More: 



8 Crucial Things to Know Before Starting Your First Job

 



Starting a new job gives me the jitters. Like traveling alone to a foreign country, it's exciting to learn and see new things but also nerve-racking to navigate logistics and interpret an alien language.

I've been on this roller-coaster before and experienced it anew this week as the new editor of Strategy and Careers here at Business Insider. I wondered, how important is that first impression and what can a professional do right from the start to set themselves up for future success?

"The first three months of any new job are an extension of the interview process," says Amanda Augustine, career expert at TheLaddersan online job-matching service for professionals. "From the first day, you need to be on your game."

With nearly a decade of experience advising high-level professionals, Augustine details what the most successful people do that first week in a new job:

1. Be a geek about introducing yourself.

Take the initiative to meet people. Say hello in the elevator, kitchen or bathroom. It will pay off in the end. "It could be a fast-paced culture, and they don't have time to come to you," says Augustine. "Start with the group that's closest to you, the people you're directly working with." It will be in their best interest to get you started on the right foot, since your work will directly affect theirs.

2. Befriend a veteran who can help you navigate politics (and find the pencils).

Learn who the players are, and who's been at your company awhile, Augustine advises. Find the battered veteran who has a good handle on what works and doesn't and can show you around. "Companies have their own language and inside jokes," she says. "Look for the one person to help you decode the acronyms and office politics." Plus, you'll need someone to go to for the silly things. Asking your boss where to find the pencils is a bit below their pay grade.

3. Set expectations with your boss and employees. "Get on your boss's calendar," says Augustine. Use that initial meeting to establish what they believe success will look like in the first week, month and three months. At the same time, if you're in a managerial position, it's important to begin setting expectations with your direct reports. From communication style to office hours, that first week sets the tone.

4. Figure out the coffee situation.

Learning where the coffee is will always be a good strategy for success. It's also important to figure out the unwritten rules of the office that, if violated, make people go ballistic. Who washes the dishes? Which shelves are communal? "In our office, there are several refrigerators, and people get upset if you use the wrong one," says Augustine. "Be a sponge, and watch how people are doing things. There's nothing wrong with asking how to use the coffee maker."

5. Start demonstrating and documenting what you sold the company on.

"Whatever you sold them on in interview, make it your mission to demonstrate that you're going to do it," Augustine says. If you said you were a social media whiz or good with numbers, immediately start revamping the social accounts or making sense of the company's analytics. And start a brag sheet. Keep track of all your accomplishments, major contributions, and when you get positive feedback. You want to get in the habit early and have the information at the ready for future performance reviews and salary negotiations.

6. Get organized to set good habits.

Especially since a lot of new information is coming your way, setting good habits and getting organized from the start will make your life easier down the line. It's also a good time to improve your bad habits. "It's a great opportunity to overcome any challenges or weaknesses from your past," says Augustine. If you've struggled with time management, for example, use that first week to map out how you'll spend each day and begin putting it into practice.

7. Reinforce your new connections on social media.

Once you're officially on the job, it's important to update your title across your own social media platforms and also start following your new company and colleagues. As you meet new people, cement the relationships by finding them on Twitter or LinkedIn. Augustine advises identifying the platform that makes the most sense. Facebook, for instance, is viewed by many as personal, so use discretion.

8. Reconnect with former colleagues.

Perhaps counterintuitively, Augustine says the first week of a new job is the perfect time to reach out to colleagues from your previous jobs. "Go back and reconnect with people at your old company, and ask for LinkedIn recommendations," she suggests. The best time to get referrals is when you're not looking for a new job, she says.

9. Find your go-to pharmacy and take-out lunch spot. Learn your new neighborhood. Do you know where the nearest CVS is? What about where to get a sandwich, take people for coffee or a nice business lunch? "Logistically, you need know where to go get a Band-Aid when you need one," Augustine says.

9 Things Successful People Do In The First Week Of A New Job

 



Follow these seven tips to help you nail down that full-time position.

1. Reach out to people you admire.

Think of those people whom you look up to in your field. Now search for their contact info and send them an email. If you can't find their email addresses, tweet at them. Send them your work, ask them for advice and even tell them why you admire them — you'll be surprised by how many people will respond positively. Starting a dialogue could lead to a potential mentorship and could even be a great resource for your job search.

Equally important is returning emails to any and all potential employers. Just acknowledging someone's email can go a long way in establishing his or her impression of you. Especially for college grads applying for jobs, even if you get rejected or turned down, it's appropriate to reply and thank your contact for his or her consideration.

If you aren't the right fit for the current position, this tactic can encourage companies to keep you in mind for future openings.

2. Consider cleaning up your social footprint.

As you look for a job, you'll probably want to make your social accounts a little more professional across the board. While you obviously shouldn't erase your entire personality from your online presence, make your best judgment when considering which tweets to delete, which profile pictures to change and which privacy settings are best for you.

There are plenty of services that can help you through your cleanse with minimal grunt work, such as FireMe! for Twitter.

3. Network in person.

LinkedIn, as useful as it is, doesn't hold a monopoly over online job networking. Using a site like Meetup.com to RSVP to in-person networking and social events is a great way to meet potential employers. You can also find volunteer work through the site, which, aside from being a great addition to your resume, can help you meet new people.

Expect awkward interactions, long nights, and lots of business cards. They're all part of the game.

4. Utilize social media as much as you can.

Aside from the obvious Linkedin, you can use plenty of your social accounts for job hunting (which makes point two on this list all the more important). Your profiles are typically some of the top results when someone Googles your name, and using them to appear more hirable won't take up too much of your time.

Consider adding your resume to your Twitter bio in the form of a public, view-only Google doc, or following job-posting blogs in your field. Search around for your school's alumni groups on social media and, more importantly, reach out to them.

5. Build something yourself.

While this will be obvious to many people in creative fields, having an online website and portfolio is a must-have for all industries these days.

Whether it's a simple online resume, a YouTube channel or a mobile game, building something yourself is a huge plus in the experience category. It proves you're passionate about your field and that you haven't been sitting around, waiting for an opportunity to come to you.

At the very least, having a personal website is tangible evidence that you have computer skills and are a serious candidate. And unless you have an unfortunately common name or share one with a celebrity, a personal domain name will help you rise to the top of search engines.

6. Set up a professional email.

Now that you're out of college, you should create a more professional email address. Whether that's simply a Gmail account of your full name or a custom address through a personal website, dropping the ".edu" from your address can make you look like more of an adult to employers.

7. Take advantage of calendars.

Set yourself a calendar reminder every few months to reconnect with former bosses and professors. This will keep you top-of-mind if any opportunities arise, giving you a shot at nailing down a job through their connections.

You can also use your calendar to designate certain days to search for jobs without interruption. Online applications and general searching can take a long time and be exhausting. Having an empty plate while you do it can be extremely helpful.

7 Pieces of Job Advice Your College Isn't Giving You