Skip to content Skip to sidebar Skip to footer
Showing posts with the label Python Internals

In Python, What Is The Difference Between F.readlines() And List(f)

From both Python2 Tutorial and Python3 Tutorial, there is a line in the midpoint of section 7.2.1 s… Read more In Python, What Is The Difference Between F.readlines() And List(f)

Why Does Tuple(set([1,"a","b","c","z","f"])) == Tuple(set(["a","b","c","z","f",1])) 85% Of The Time With Hash Randomization Enabled?

Given Zero Piraeus' answer to another question, we have that x = tuple(set([1, 'a', … Read more Why Does Tuple(set([1,"a","b","c","z","f"])) == Tuple(set(["a","b","c","z","f",1])) 85% Of The Time With Hash Randomization Enabled?

How Does Module Loading Work In Cpython?

How does module loading work in CPython under the hood? Especially, how does the dynamic loading of… Read more How Does Module Loading Work In Cpython?

What's The Runtime Of Python's Strip()?

What's the runtime of Python's strip()? Since remove is O(n) for a single char, is strip O(… Read more What's The Runtime Of Python's Strip()?

Why Is It Slower To Iterate Over A Small String Than A Small List?

I was playing around with timeit and noticed that doing a simple list comprehension over a small st… Read more Why Is It Slower To Iterate Over A Small String Than A Small List?

When To Use `<>` And `!=` Operators?

Couldn't find much on this. Trying to compare 2 values, but they can't be equal. In my case… Read more When To Use `<>` And `!=` Operators?

Python 3.4 Multiprocessing Queue Faster Than Pipe, Unexpected

I am doing an audio player that received samples from an udp socket, and everything was working fin… Read more Python 3.4 Multiprocessing Queue Faster Than Pipe, Unexpected

Making An Object X Such That "x In [x]" Returns False

If we make a pathological potato like this: >>> class Potato: ... def __eq__(self, oth… Read more Making An Object X Such That "x In [x]" Returns False

Efficiency Of Sorting By Multiple Keys In Python

I have a list of strings that I want to sort by two custom key functions in Python 3.6. Comparing t… Read more Efficiency Of Sorting By Multiple Keys In Python

In-place Custom Object Unpacking Different Behavior With __getitem__ Python 3.5 Vs Python 3.6

a follow-up question on this question: i ran the code below on python 3.5 and python 3.6 - with ver… Read more In-place Custom Object Unpacking Different Behavior With __getitem__ Python 3.5 Vs Python 3.6

Why Does Tuple(set([1,"a","b","c","z","f"])) == Tuple(set(["a","b","c","z","f",1])) 85% Of The Time With Hash Randomization Enabled?

Given Zero Piraeus' answer to another question, we have that x = tuple(set([1, 'a', … Read more Why Does Tuple(set([1,"a","b","c","z","f"])) == Tuple(set(["a","b","c","z","f",1])) 85% Of The Time With Hash Randomization Enabled?

Python 3 Integer Addresses

x=300 y=300 print(id(x),id(y)) a=[300,300] print(id(a[0]),id(a[1])) On executing above code I get … Read more Python 3 Integer Addresses

Why Isn't My Dict Lookup Faster Than My List Lookup In Python?

I'm reading each line of a file into both a list and a dict, with open('../data/title/prune… Read more Why Isn't My Dict Lookup Faster Than My List Lookup In Python?