/dpt/ - Daily Python Thread

What species of snake are you caring for, Sup Forums?

Previous thread:

Other urls found in this thread:

privatebin.net/
ybin.me/
pastebin.com/VFNkZ6X1
call-cc.org/
msdn.microsoft.com/en-us/library/dd78zt0c(v=vs.110).aspx
cs.utah.edu/~arichard/monad.html
youtube.com/watch?v=LIMd2kF8Ci4
twitter.com/NSFWRedditImage

OP is a faggot

Is it worth learning Android now? Tempted to do Udacity's nanodegree

I would have thought Android to be a busted flush at this point

any curl users? im wondering if i can use
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, &progress_callback);
in curl_multi interface

I'm doing my babbys first multithreading on C# with Parallel.For, and I'm using nested loops

when I make the outer loop parallel, everything works just fine, but if I make the inner loop parallel the results get completely skewed for no reason, what is going wrong?

It's quite a bit of code, can anyone point me to a website where I can put it so you can see?

ghostbin or hastebin

does the dragon book teach any assembly?

Ghostbin has google analytics botnet

privatebin.net/
ybin.me/

>Ghostbin has google analytics botnet
>ybin.me/
>gstatic tracker

I ended up using pastebin, but thanks for the suggestions

pastebin.com/VFNkZ6X1

the outer loop (Line 4) works fine in parallel
the inner loop (Line 31) shits itself while checking who wins (Line 59) if it's running in parallel instead

I tried to use lock() on that checking part but the results are still the same

i could never get curl_multi to work right, it would always randomly truncate files

> static object lel
> lel

stoppped reading there

>setting non-init variables in loops

From a glance you need to get rid of those nested if/else

Your inner loop is mutating variables outside itself, e.g. K_HP. If you can, move the declarations of K_HP, D_HP, K_ATK, D_ATK, K_DEF, and D_DEF inside the inner loop, and put K_W, D_W, and Tie inside atomic references.

>If you can, move the declarations of K_HP, D_HP, K_ATK, D_ATK, K_DEF, and D_DEF inside the inner loop
I can do that, they were like that before

>put K_W, D_W, and Tie inside atomic references
I'll read about what that is, then I'll return to you

thanks for the pointers user

>can't eat Doritos and program at the same time

>eating literal poison
stop

I don't know what C# calls it, but in Java using AtomicInteger instead of int for K_W etc. is what I'd do.

would creating a compiler be as simple as having a toy language that i translate into a C program, by giving the program's source as input to an exeuctable which outputs the resulting program and then uses gcc to compile it?

I'll worry about my long-term health once I stop wanting to kill myself every 5 minutes.

that's literally how C began, as transpiled asm

>wanting to kill myself every 5 minutes.
why?

switch to jalapenos, much healthier

Don't you take your hands off the keyboard to think occasionally? Your code isn't that brainless and rote right?

Yeah it's pretty common actually. This compiler does that: call-cc.org/

Not a bad idea. But consider C-- instead of C.

CHICKEN now runs on Windows without cygwin? Fuck yeah, that's awesome!

you always do a restriction of the language (subset) not the entire language.

the entire language takes too much work imo

Yeah perhaps that's even smarter.

What are the upper division computer systems courses like? I'm about to finish my prerequisites and I wanna go into networking and operatig Systems

What's an upper division?

Where to begin:
>still live at home
>burden to parents
>entering senior year at Uni studying CS, but I've never had a single internship, leaving me with dwindling career prospects
>social prospects are even worse
>no friends IRL or online and I have no one but myself to blame
>so in my own head that all aspects of interacting with people seem contrived and exhausting so I barely even try anymore, which contributes to me again having no friends
>brainlet
>I've been programming for years but I still feel like a retard and understand little/nothing of the discussion in these threads
I could go on.

That would be a transpiler.

3000-4000 level courses at uni. They're the advanced undergrad courses

Fuck, where?

Using c-- removes one of the biggest advantages of transpiling to c, portability.

>ybin.me/
at least, that's what my ublock origin shows

don't know what pic related means tho

I need help with deploytment.

My project consists of dozens of processes that collect data from various sources. They need to be restarted reliably whenever updates are pushed to Git.
What I need is a process monitor with an RPC API that I can call from a git hook. I could ghetto rig my own solution but surely an orchestrating software must exist already, polished and relatively bug free.

TLDR: Looking for micro service orchestration software

>social prospects are even worse
>no friends IRL or online and I have no one but myself to blame
if you want friends, you can join a club or something like that (or play a team sports)

>entering senior year at Uni studying CS, but I've never had a single internship, leaving me with dwindling career prospects
are you applying though? it's alright if you send 50 curriculums and only receive like 2 calls back. at least you're trying

>I've been programming for years but I still feel like a retard and understand little/nothing of the discussion in these threads
you're slacking. you don't set goals for yourself

that's my shitty advice

>Same as you except I went to a community college.
>I want to study engineering, but I'm already 23. Not sure what to do.
>Lost my job as a gamedev on February.
>I hate my third world country. Job remuneration sucks here.
>Still haven't got a new job.
>Learning a lot of webdev aiming to get a job at germany or somewhere else with paid relocation.
>No friends, I'm an antisocial. Don't go out of my house.
>Live with parents, want to get the fuck out, but I don't want to get again in a crappy local job burning me out for almost no pay.
>I'm really sick, some cardiovascular issues, hands red wrinkled and skin burning, blue veins visible on my hands and below my eyes.
>I piss myself and I'm having trouble digesting food.
>24hs migraine, pain on knees and bones, but I keep doing exercise or else the fatigue makes me sleepy.
>No one cares, the doctor I went to is dumb as fuck.
So I just try to learn everything I can to get a job, while I don't have a life.

code/programming will save your life.

keep pushing

Or kill me at the end. But dying would be a relief by now. At least experienced the basics of life.

Mine is gstatic free, idk

Udacity is the biggest piece of shit waste of time known to mankind. No matter what it is you are doing, Udacity is not the answer.

i'm at windows at the moment, not Linux.

you? could be from that idk

What's better?

Blend your doritos with your mountain dew and drink it through a straw.

Sup Forums should really make its own pasta site, called eb.in or something

I tried using Interlocked.Increment() msdn.microsoft.com/en-us/library/dd78zt0c(v=vs.110).aspx on K_W, D_W and Ties but had no success, will try some other ways i've found, but I don't know if it will work

Not a bad project idea desu.

Literally anything else. Udacity is like an anti-learning resource, everything I've tested on there is basically completely worthless for teaching. It's laughable.

learning from a book and posting your progress on Sup Forums, for people to mock you and from that you improve.

>Says python
>posts corn snake

you should have ended it before you made a thread

Yes, but if youjust need to shit out some mobile apps use cordova (apache).

oh wait, I think I know the issue, brb

we got an /an/ expert ova here

a snek is a snek

this is what happens when you don't use an anime image for OP

it's probably beacause of my host lists
on winbotnet too atm
ok, but who will pay for hosting/domain?

post more code

>/an/
>expert
/an/ are a bunch of dog dick suckers

/an/ seem okay desu.

I put lock when using the RNG and it worked, now the results came in properly

>hair-seizure.webm

Good job user. I guess the RNGs aren't threadsafe.

Are you Australian?

>this
>python
Are you retarded?

Why would you want him to post python?
Python is a disgusting language

it's running 2 times slower unfortunately, but it at least can scale a lot more with thread count compared to the first implementation, that would only make use of 10 threads at most

thanks for all the help user

Yeah, there'll be some overhead from making the inner loop thread-safe. You might be able to improve upon it further by having each thread keep track of its own results (which would allow you to avoid the overhead of Interlocked), and combine the results at the end. Not sure how complex that would be to implement in C#.

Would you prefer JCL?

Rewriting my raycaster. There seems to be precision issues though, I suspect due to catastrophic cancellation in the dot product. I'm going to have to rewrite datenwolf's linmath.h to use doubles and kahan summation it seems.
void finite_pick_with_side_ll_v2(finiteworld * f, float x, float y, float z, int * output) {
finite_pick_ll(f,x,y,z,camera_angle[0],camera_angle[1],camera_angle[2],4,output);
if(output[0] == 0)
return;

block * b = finite_getblock(f, output[1], output[2], output[3]);
model_raytest_rect * raytests;
int quadcount;
switch(b->type) {
case MODEL:
raytests = b->u.m.m->raytests;
quadcount = b->u.m.m->vertcount / 6;
break;
default:
raytests = block_modelblock->u.m.m->raytests;
quadcount = block_modelblock->u.m.m->vertcount / 6;
}
vec3 tmp;
vec3 intersection;
vec3 camera_pos; //relative to block
camera_pos[0] = x - output[1];
camera_pos[1] = y - output[2];
camera_pos[2] = z - output[3];
//XXX n & u & v & v0 are rotation dependent
//so they will need to be recalculated if the model is rotated
//TODO switch to doubles, precision errors at extreme angles at seams
for(model_raytest_rect * rect = raytests; rect < raytests + quadcount; rect++) {
float camera_dot_quad = vec3_mul_inner(rect->n, camera_angle);
//Ray faces away from quad
if(camera_dot_quad v0, camera_pos);
float t = vec3_mul_inner(rect->n, tmp) / camera_dot_quad;
vec3_scale(tmp, camera_angle, t);
vec3_add(intersection, tmp, camera_pos);
vec3_sub(tmp, intersection, rect->v0);
float s = rect->negvnorm * vec3_mul_inner(tmp, rect->u) / rect->k;
t = rect->negunorm * vec3_mul_inner(tmp, rect->v) / rect->k;
if((0

This isn't an ugly language dick waving contest.

All languages are ugly, NO EXCEPTIONS. Some languages are just more less ugly than others.

feels

the largest overhead is on the RNG locks as far as I can tell since it was running faster (but shitting on the results) before putting them there

>What species of snake are you caring for, Sup Forums?

Exploring the deepest, darkest corners of Rackets.

sml for mutually recursive data structures is gorgeous

I think I finally understand "moan ads" /dpt/. Still have trouble with more complicated ones like Cont though

Hutton book is a decent resource

Why would you put a filter over your screenshot?

there is no filter

How do you implement a monad in ANSI C?

you don't need monad in c since it's imperative at its very core.

cs.utah.edu/~arichard/monad.html

How have I done?

#ifndef _STDIO_H
#include
#endif

enum {INT, FLOAT};

typedef struct Number{
int type;
union val{
int i;
float f;
} val;
} Number;

Number addTwoNumbers(Number i, Number j){
Number tempNum = {
.type = INT,
.val.i = 0
};

if((i.type == INT) && (j.type == INT)){
tempNum.type = INT;
tempNum.val.i = i.val.i + j.val.i;
}
else if((i.type == FLOAT) && (j.type == INT)){
tempNum.type = FLOAT;
tempNum.val.f = i.val.f + (float)j.val.i;
}
else if((i.type == INT) && (j.type == FLOAT)){
tempNum.type = FLOAT;
tempNum.val.f = (float)i.val.i + j.val.f;
}
else if((i.type == FLOAT) && (j.type == FLOAT)){
tempNum.type = FLOAT;
tempNum.val.f = i.val.f + j.val.f;
}
return tempNum;
}

void printSum(Number x, Number y){
Number tempNum = addTwoNumbers(x, y);
printf((tempNum.type == INT ? "%d" : "%f"), (tempNum.type == INT ? tempNum.val.i : tempNum.val.f));
}

#include
#include "twonum.h"

int main(){
Number one = {INT, .val.i = 5};
Number two = {INT, .val.i = -2};

Number three = addTwoNumbers(one, two);
printf("%d\n", three.val.i);

two.type = FLOAT;
two.val.f = 4.0;

printSum(one, two);
}

Python is a cute!

The lengths people go to, in order to attempt to make C appear modern, is sad.

youtube.com/watch?v=LIMd2kF8Ci4

Is that a snake yawn?

Float conversion is implicit due to type promotion.. You can remove it.

Pretty sure that preprocessor stuff at the top is superflous, it's not 1974 and I'm sure by now any decent implementation already has include guards in the standard library header (and any implementation that DOESN'T have that probably doesn't support enums either).

I believe it's to realign the jaw

C is modern enough.
Name one thing a language can do that C can't do that actually has a point to it and isn't just disgusting bloat.

Non-C++ templates are good though.
slice & ranges.
UFCS.
modules.

to start.

Note: if the end result looks and feels hackish it doesnt count.

no bias detected in this post

Done, although I had thought the compiler complained about implicit something-or-other when I hadn't included stdio.h in the header.

enum {INT, FLOAT};

typedef struct Number{
int type;
union val{
int i;
float f;
} val;
} Number;

Number addTwoNumbers(Number i, Number j){
Number tempNum = {
.type = INT,
.val.i = 0
};

if((i.type == INT) && (j.type == INT)){
tempNum.type = INT;
tempNum.val.i = i.val.i + j.val.i;
}
else{
tempNum.type = FLOAT;
tempNum.val.f = ((i.type == INT) ? i.val.i : i.val.f)
+ ((j.type == INT) ? j.val.i : j.val.f);
}
return tempNum;
}

void printSum(Number x, Number y){
Number tempNum = addTwoNumbers(x, y);
printf((tempNum.type == INT ? "%d" : "%f"),
(tempNum.type == INT ? tempNum.val.i : tempNum.val.f));
}

Oh, I don't mean remove the #include , that's pretty much neccessary for programming in a modern style, but the #ifndef or whatever around it is superfluous.

>Non-C++ templates are good though.
Macros.
Alternatively void*. (This is my preferred approach. If the behavior of the function or struct should be type invariant, why even have a parameter for the type at all, and if it shouldn't, why even make it generic.)
>Note: if the end result looks and feels hackish it doesnt count.
It's not hackish. It's a proper use case for macros.

>slice & ranges.
struct range {
void *start;
size_t len; // in chars
};


>UFCS.
Not applicable, C has no receivers. IMO that's a positive quality about it.

>modules.
A header isn't a module, but a compilation unit basically is.

Ah! I only got the warning message when I try to compile the header separately.
That makes more sense. Apologies for the incompetence: I haven't noodled about with headers before.