Saturday, 3 December 2016

Interesting Python Links

Here is a few, I think, worth checking links:
https://boltons.readthedocs.io/en/latest/debugutils.html
http://www.oreilly.com/programming/free/20-python-libraries-you-arent-using-but-should.csp
http://pybee.org/
https://automatetheboringstuff.com/
Enjoy!


Effective Overflow Testing (Bit Hacks II)

The post is in fact the second part of this. I reproduce from the book test for overflow in multiplication two  unsigned 32 bit integers, and extended it to unsigned longs (64 bit unsigned). The basic idea is to check sum  of leading zeroes (for 64 bits reasoning is the same) in 64 bit factors (when checking 32 bits). When the number is greater or equal than 32 (nlz(x) + nlz(y)) the multipliction does not overflow, when is less than 31 overflows; when equal to 31 is uncertain - additional checks are to be made.  
    Function is fast, there was no time difference when check run in a loop, precedding multiplication.
Code here (I'm moving from bitbucket, seems these days, everybody has github account from birthday-:)).

Tuesday, 29 November 2016

Profiling Python Code in Jupyter Notebook

   You probably know, that there is a cool stuff: jupyter notebook. I've recently implemented some data structures in python.  
    Here, there is a, call it, "live session" of profilling one of them in the notebook and I think, notebook is great tool to it.





Sunday, 20 November 2016

Python Data Structures

Playing with python3, I've written some data structures implementations - AVL tree, double linked list and min heap. Code here.    
    Anybody learning python welcome to test them, there is also place to implement more functionalities, like  min, max in AVL or reverse list.  
   More code will, hopefully,  come soon.

Wednesday, 16 November 2016

Bit Tricks

After reading some passages from fantastic Henry S. Warren  "Hacker's Delights", I've implented and tested few functions. Code with commentary here .
    Works faster (sometimes 2 times) than naive implementation, and not worst than functions from math.h, I enabled all compiler optimizations. Feel free to check how it works in java or C#!

Wednesday, 9 November 2016

Map, filter and reduce in C.

I think, this is useless, but I've written map, filter and reduce in C. Code here. No side effects, pure functions, tail recursive, well... iterative;)

Monday, 7 November 2016

Few Benchmarks

I've recently played with ipython notebook, and decided to make some speed comparisons, between java, python and scheme (racket)  - can be viewed here.

Edit! After small changes results has changed too.
Edit2! Additional tests here.