-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3de37e5
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.pp.c | ||
*.asm | ||
*.o | ||
*.e | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Compiled languages into Python | ||
|
||
En este hands-on vamos a practicar cómo llamar a una librería | ||
nuestra desde python. En la carpeta `src/` tienen dos archivos de C. | ||
Para completar este ejercicio tienen que hacer los siguientes pasos: | ||
|
||
1. Compilar ambos archivos como objetos separados | ||
2. Construir una librería dinámica que tenga ambos objetos | ||
3. Escribir un script en python que pruebe **todas** las funciones | ||
de la librería |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* file: add_two.c */ | ||
|
||
float add_float(float a, float b) { | ||
return a + b; | ||
} | ||
|
||
int add_int(int a, int b) { | ||
return a + b; | ||
} | ||
|
||
int add_float_ref(float *a, float *b, float *c) { | ||
*c = *a + *b; | ||
return 0; | ||
} | ||
|
||
int add_int_ref(int *a, int *b, int *c) { | ||
*c = *a + *b; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* file: arrays.c */ | ||
|
||
int add_int_array(int *a, int *b, int *c, int n) { | ||
int i; | ||
for (i = 0; i < n; i++) { | ||
c[i] = a[i] + b[i]; | ||
} | ||
return 0; | ||
} | ||
|
||
float dot_product(float *a, float *b, int n) { | ||
float res; | ||
int i; | ||
res = 0; | ||
for (i = 0; i < n; i++) { | ||
res = res + a[i] * b[i]; | ||
} | ||
return res; | ||
} |