mtbc: maze I (white-red)
[personal profile] mtbc
For our software at work we use Python in some components. I am not much of a fan of Python — for me it brings the worst of Perl while omitting the best — but I have been trying to become more comfortable with it. I have found it easy to write buggy code: for instance, flake8 is quite happy with,
x = 'foo'
for x in range(5):
    pass
print(x)
That prints 4 which means that I must be very careful about tracking variable names: scoping may not be as I expect.

I have also found myself having to be wary in other ways. For example, recently I tried experimenting with the multiprocessing module and if too careless then I am easily surprised. If I fire off a process to print something to standard output then return a result, then having gotten that result and written something else to standard output, those output lines may appear out of order if I do not first join() from that other process, at least unless I manually flush or adjust buffering. Or, if I pass an object as an argument to apply_async or somesuch, it may effectively get passed by value instead of by reference so its state changes are lost as side-effects: I must remember that data may be pickled on its way about. In some situations it thus turns out that I must be doubly wary.

I have a large multidimensional numpy array that I was hoping to have multiple processes read from without copying it around. On trying to work out correspondences between ctypes and dtypes and whatnot I kind of gave up there and figured that I would prefer a night's sleep.

Profile

mtbc: photograph of me (Default)
Mark T. B. Carroll

January 2026

S M T W T F S
    123
456789 10
11121314151617
18 192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 20th, 2026 03:10 pm
Powered by Dreamwidth Studios