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

Is An Explicit Nul-byte Necessary At The End Of A Bytearray For Cython To Be Able To Convert It To A Null-terminated C-string

When converting a bytearray-object (or a bytes-object for that matter) to a C-string, the cython-do… Read more Is An Explicit Nul-byte Necessary At The End Of A Bytearray For Cython To Be Able To Convert It To A Null-terminated C-string

Why Is 'new_file += Line + String' So Much Faster Than 'new_file = New_file + Line + String'?

Our code takes 10 minutes to siphon thru 68,000 records when we use: new_file = new_file + line + s… Read more Why Is 'new_file += Line + String' So Much Faster Than 'new_file = New_file + Line + String'?

How Does __slots__ Avoid A Dictionary Lookup?

I've heard that __slots__ makes objects faster by avoiding a dictionary lookup. My confusion co… Read more How Does __slots__ Avoid A Dictionary Lookup?

Memory Size Of List Python

I was experimenting something with lists and I came around self-referencing lists. I searched throu… Read more Memory Size Of List Python

Why Don't Tuples Get The Same Id When Assigned The Same Values?

When I executed the following steps, both tuples (a and b) haven't retained their original IDs … Read more Why Don't Tuples Get The Same Id When Assigned The Same Values?

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: Which Types Support Weak References?

Code: from weakref import WeakSet se = WeakSet() se.add(1) Output: TypeError: cannot create weak r… Read more Python: Which Types Support Weak References?

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)