When performance matters

Using Lists when dealing with large dataset is not always the best choice. As the data gets too big it will quickly consume your computer’s memory. That’s when you should consider using Python’s Generators. Let’s say you want to calculcate the sum of 10 000 items: 1 2 3 my_dataset = [i for i in range(10000)] print(sum(my_dataset)) #49995000 This would of course work, but the impact on memory would be very high. We can do the same thing with generators and then compare the sizes. ...

December 15, 2022 · 2 min · 232 words

Continuous learning

I’m currently reading Pragmatic programmer, a book that is considered a bible for software developers. I’m approximately 1/3 in and just read a section about (continuous) learning. Effective learning is a huge topic in itself. I plan to explore it in the future and summarize what I have learned so far from the books I have read and podcasts I have listened to regarding this topic. Anyway, I really like the suggestions from the authors of the book about improving your learning process, they suggest you to: ...

December 15, 2022 · 1 min · 189 words

Removing duplicate values

Next useful Python feature is Set(). Set is another built-in data structure used for storing data (other 3 are List, Tuple and Dictionary). A set is a collection which is unordered, unchangeable*, and unindexed. The most important feature of Set() is that it does not allow duplicate values. 1 2 3 4 5 6 7 numbers = [1, 1, 2, 3, 4, 5, 5, 5, 6, 7] my_set = set(numbers) print(myset) # {1, 2, 3, 4, 5, 6, 7} How it helped me? In my Job-scraper, after analazing job’s keywords, I am appending the list of found keywords into a Job dictionary, but first I convert the list into a set: ...

December 14, 2022 · 1 min · 204 words

Sorting complex iterables

Sorting is an important feature of any programming language. Having a large set of data that you can’t sort and have to check values one by one wouldn’t get you very far. There is a large number of sorting algorithms to which I was first introduced in (in my opinion) one of the best online courses, Harvard’s CS50 Introduction to Computer Science. Sorting algorithms is a huge topic that I want to explore further in the future. I believe understanding here is very useful when building complex programs where performance is key, but for everyday programs Python’s built-in sorted() function is probably more than enough when one needs to sort an iterable. I’m not really familiar what algorithm it uses and its performance, but that’s for future exploration. ...

December 13, 2022 · 2 min · 329 words

Using Custom User Model

Django is currently my favorite framework when it comes to building web applications. I was first introduced to Django during my course CS50’s Web Programming with Python and JavaScript. It’s a fully featured framework, that comes with pretty much everything one would need for a modern web application. But what’s even more important is, the framework is very flexible and customizable. And just like for Python, there is a huge network of 3rd party packages and huge community around Django. ...

December 12, 2022 · 3 min · 456 words

Append items into List

No matter what exactly are you working on, if you are working with data, you also need a place where you can store this data. There are many options and which one you choose depends on your wished outcome. A very straightforward way of storing any kind of data are Arrays, or Lists, as they are named in Python. Lists are one of 4 built-in data types in Python used to store collections of data, the other 3 are Tuple, Set, and Dictionary, all with different qualities and usage. ...

December 11, 2022 · 2 min · 366 words

Pythonic way of iteration

Python is amazing. My understanding so far is that all programming languages can do, at the fundamental level, pretty much the same things - they just all do it in their own way. And Python has some really unique ways of doing regular things. These are so unique to Python, they even received their own term - writing pythonic code. One of these features is iteration. When you need to access both the item and its index, traditionally you would loop over the length of the list and use index to access the item. ...

December 10, 2022 · 1 min · 205 words