←back to thread

490 points jarmitage | 1 comments | | HN request time: 0.2s | source
Show context
paulluuk ◴[] No.40681492[source]
While this is really cool, I have to say..

> import warp as wp

Can we please not copy this convention over from numpy? In the example script, you use 17 characters to write this just to save 18 characters later on in the script. Just import the warp commands you use, or if you really want "import warp", but don't rename imported libraries, please.

replies(5): >>40681523 #>>40681706 #>>40681974 #>>40683394 #>>40685824 #
hoosieree ◴[] No.40681974[source]
The more Python I write, the more I feel that "from foo import name1,name2,nameN" is The Way. Yes it's more verbose. Yes it loses any benefits of namespaces. However it encourages you to focus on your actual problem rather than hypothetical problems you might have someday, and the namespace clashes might have a positive unintended consequence of making you realize you don't actually need that other library after all.
replies(2): >>40683519 #>>40712466 #
1. hot_gril ◴[] No.40712466[source]
It's unlikely that two things with the same name in different packages do the same thing. It's also kinda unlikely that you have a collision in the first place. And if the theoretical problem with `import numpy as np` is that you forget what `np` is, then using `array` instead of `np.array` will have the same problem.

At the end of the day, this is a minuscule issue either way. I won't import stuff your way, but if you hand me code like that, I won't change it.