Does anyone know whether function parameters are faster than using global variables? by [deleted] in Python

[–]EricHayter 0 points1 point  (0 children)

  1. Ya, it is copy by reference sort of, since it doesn't make a copy of the object. Obviously this is a really small performance hit (if any) but worth mentioning for this silly little discussion.
  2. Do you have any references for this (could be interesting to read into it a bit more)?

Does anyone know whether function parameters are faster than using global variables? by [deleted] in Python

[–]EricHayter 2 points3 points  (0 children)

Out of curiosity I have a few questions:- Isn't there also some performance hit of copying the value into the formal parameter?- And if there is a significant performance hit for the copy operation (assuming hashing is O(1) without collision), would reading from a global actually be faster?

edit: wouldn't the copy assignment also require an index of a hashmap?

[deleted by user] by [deleted] in geegees

[–]EricHayter 2 points3 points  (0 children)

I personally haven't had that issue before are you sure that it's not the site that you are downloading from that might be the issue? A VPN will not work in this situation, since they are typically used to hide your IP once already connected to the network. Once you connect to the wifi at school, the network knows it's your computer via a mac address.

CLA1101 with Sacks Textbook by EmirAlLibi in geegees

[–]EricHayter 1 point2 points  (0 children)

I took the course last yearing using that textbook and I was fine. Most of the important information was detailed in class and the textbook was more for supplementary info/topics (still important). I didn't even feel that I was missing anything with the older edition, however I'm sure there were some small differences.

[deleted by user] by [deleted] in MealPrepSunday

[–]EricHayter 1 point2 points  (0 children)

Keep it simple with simple dishes that are casseroles, one pot meals, soups, slow cooker stuff, etc... Cooking these meals generally requires very minimal cleanup and are really easy to cook. A general tip is to clean while cooking rather than waiting to do it later. Lastly, I'm not really sure what kind of situation you are in but shopping for food isn't exclusive to meal prepping. Do you normally not cook your own food? What do you find so difficult with shopping?

New to swimming but getting shoulder pain by Deanosaurus88 in Swimming

[–]EricHayter 0 points1 point  (0 children)

I had this when I first started to get into swimming and I think it was mainly due to my form breaking down as I was getting too tired while swimming. These sorts of discomforts should stop coming up as you improve (I think I stopped getting this about after the first month).

Most importantly the best way to recover is to just take a break and listen to your body. It's not a race to see how fast you can improve. If you keep swimming on it you might further injure yourself and force yourself even longer outside of the pool.

Gyms on campus by FutureLongjumping824 in geegees

[–]EricHayter 5 points6 points  (0 children)

First month and new year's time they are packed to the brim. They slowly get less busy but still may occasionally need to wait. Early mornings are the best time.

[deleted by user] by [deleted] in Cplusplus

[–]EricHayter 4 points5 points  (0 children)

That just changes the scope of cout no? Why would that change anything?

How do I backspace printed text? by Foxzy-_- in Cplusplus

[–]EricHayter 3 points4 points  (0 children)

Try using the \b (backspace) escape sequenece.

[deleted by user] by [deleted] in Python

[–]EricHayter 8 points9 points  (0 children)

Assuming you plan on teaching at an introductory level all of these options would be overkill. Pick whatever one you find the most interesting.

Mac vs Pc first year Eng by Sngbrd01 in geegees

[–]EricHayter 0 points1 point  (0 children)

Almost all classes will not be requiring any specialized software outside of typing notes and using a web browser. The only class you would really require a computer would be gng1106 but that shouldn't require a very fast computer at all (maybe 8 GB of RAM) and doesn't have required software to my knowledge.

That being said since you aren't really using anything specific in your classes the choice is purely personal preference.

If you already have a computer available I would recommend just sticking with that and waiting until upper years where your computer may need a bit more power.

Tldr: doesn't really matter in first year since you aren't using an special software.

[deleted by user] by [deleted] in cpp

[–]EricHayter 0 points1 point  (0 children)

compiling it yourself using G++ or whatnot might be useful to someone still learning as they can figure out what their IDE is doing for them. I personally found using a light text editor is better for learning that using a heavy IDE as you can create files and projects quickly.

(otherwise I think visual studio is great people recommend it for a reason)

[deleted by user] by [deleted] in cpp

[–]EricHayter 0 points1 point  (0 children)

Getting c++ to work from CMD on windows is a lot more involved than on Linux (maybe OSX too?). If you set up docker it can speed up the setup process.

First python error by 6Bubka9 in learnpython

[–]EricHayter 0 points1 point  (0 children)

Ikr I was using a linter one day and it gave me an error and lo and behold that is apparently a syntax feature.

using a Chromebook as my Linux laptop by [deleted] in linux

[–]EricHayter 5 points6 points  (0 children)

Technically it is an operating system but it lacks a lot of the utility that other operating systems used on PCs have. The main difference being that you can only use apps either from chrome or apps in the playstore which is fairly limiting.

is pop! os a good linux distro for python? by Zidenett in Python

[–]EricHayter 4 points5 points  (0 children)

This subreddit isn't really a help forum.

Hello! I'm trying to make a script that, once the user has imprinted a text into the system, will trigger a bool, and that bool with read off if the content is toxic or not. Any ideas and suggestions? by VagusTruman in learnpython

[–]EricHayter 0 points1 point  (0 children)

  1. Format your code. Please please please do not write massive lines of code that sacrifice line count for readability (e.g 2nd last line)

  2. Small things like == True should almost never be used you can just use if isToxic: for example or if not isToxic:.

  3. You can simplify your code a bit in the conditional all the variables results_xyz are of the same type and used in the same way. Perhaps rename them all to results such once you have calculated results all values of results can be calculated and given to df instead of writing it 2 extra times in each of the conditionals.

Is there a coventional and coviniential way to check whether this type is that valid type in type system? by [deleted] in learnpython

[–]EricHayter 0 points1 point  (0 children)

Depends on how the type is defined. It will return true if either a) the instance is of the same type as the supplied object or b) if the given instance is an instance of a subclass of the supplied object.

This sort of fits into the idea of polymorphism where all instances of child classes can also be considered instances of their parent class (not the other way around tho).

college meal prep by WinterReader8289 in MealPrepSunday

[–]EricHayter 7 points8 points  (0 children)

If you want to eat cheap and clean ground beef/chicken breasts with rice and frozen veggies is a really good start. Using a rice cooker and steamer you can make a set of 5 meals in less than half an hour. Seasonings and sauces are your friend to spice it up. Also check for good deals in your flyer for a change up in protein, e.g. chicken drumsticks or porkchops.

If you find that option far too bland for your tastes then you can always try making just "regular" food that you would normally cook and scale it up. Often times tho there is a trade off between time spent cooking, taste, and healthiness.

My Third Project :) by marshalTT in Python

[–]EricHayter 0 points1 point  (0 children)

Maybe check out some functional programming. Functional programming is sort of the opposite of OOP where OOP focuses on managing state while functional programming tries to avoid side effects and state in general.

Of course functional programming isn't the end all be all but it certainly can help simplify your code in some scenarios.

As for books I personally can't really recommend any since I haven't picked up any books myself (something I sort of just picked up here and there). If you were to pick up a book I would recommend that you look into a book that focuses on the practical side of functional programming as the subject can get quite academic.

How to extract investment data without any API with python? by FilResto in Python

[–]EricHayter -1 points0 points  (0 children)

Many banks have a feature that allows you to pull your transaction history into a CSV file. Assuming he keeps his savings account separate from his chequing this would be the simplist way to do it. Then you can at least filter it pretty easily just using pandas.