Alexandre B A Villares 🐍 on Nostr: Hey #Python #numpy friends, which is better/faster? Are they the same? triangles_conc ...
Hey #Python #numpy friends, which is better/faster? Are they the same?
triangles_conc = np.concatenate((a, b, c), axis=1).reshape(-1, 2)
triangles_stack = np.hstack((a, b, c)).reshape(-1, 2)
Context: Drawing "boids" as triangles.
triangles = np.hstack(
(left_points, right_points, head_points)).reshape(-1, 2)
with py5.begin_shape(py5.TRIANGLES):
py5.vertices(triangles)
#py5 #boids
Published at
2023-11-20 15:32:43Event JSON
{
"id": "b0c7e933612e0dd716b3d72534a84bbb1c26fe410d6fa86cf9f78ff3f01cafc2",
"pubkey": "883b5e42e69fa4eb2bee76e555c217028b48dc7676f61453c7f506fd1a33ab62",
"created_at": 1700494363,
"kind": 1,
"tags": [
[
"t",
"python"
],
[
"t",
"numpy"
],
[
"t",
"py5"
],
[
"t",
"boids"
],
[
"proxy",
"https://ciberlandia.pt/users/villares/statuses/111443598625713720",
"activitypub"
]
],
"content": "Hey #Python #numpy friends, which is better/faster? Are they the same?\n\ntriangles_conc = np.concatenate((a, b, c), axis=1).reshape(-1, 2)\n\ntriangles_stack = np.hstack((a, b, c)).reshape(-1, 2)\n\n\nContext: Drawing \"boids\" as triangles.\n\ntriangles = np.hstack(\n (left_points, right_points, head_points)).reshape(-1, 2)\nwith py5.begin_shape(py5.TRIANGLES):\n py5.vertices(triangles)\n\n\n#py5 #boids\n\nhttps://ciberlandia.pt/system/media_attachments/files/111/443/593/764/811/625/original/eaa979631c02ac4b.png",
"sig": "f8e3c286569b8667139543671a737718c053f71f8ce1d80779bf03a9200a78eea105427104b169ffaec561e74bf5bc21f85960d737bd341ca948a5addb5c6610"
}