#πŸ”’ how do i make this faster + general code review

20 messages Β· Page 1 of 1 (latest)

worn iris
#

got this little thing that converts a 3d model into a minecraft structure
its really slow as in a 16x16x16 render of 3dbenchy took almost 7m and it grows exponentialy. how do i make it faster
any code review is apprechiated this is mostly a quick project so i didnt focus much on looks but im still open to thoughts

thick umbraBOT
#

@worn iris

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sand totem
#

in contains_batched(), you create the variable l, but then proceed to use len(points) again

#

I see that you also only use l once after that

#

instead I would just use len(points) in that one instance

worn iris
#

ye some parts are chat gpt + hand fix

sand totem
#

welp, I'm out

worn iris
#

proove me wrong but i think i understand most of it

#
xs, ys, zs = np.meshgrid(
        np.arange(size[0]),
        np.arange(size[1]),
        np.arange(size[2]),
        indexing="ij",
    )
    points = np.stack((xs, ys, zs), axis=-1).reshape(-1, 3)

this part upsets me the rest i get and now that i think about it only like the batcher is chatgpt code

marble tide
#

just ask chatgpt to unserialize it into a forloop so you can see whats happening

worn iris
#

whats serialized?

marble tide
#

instead of a oneliner

worn iris
#

also its obvious that the mesh.contains(chunk) call is taking minutes but idk how to optimize that
do i break up the model? if so how?

marble tide
#

or pethaps im wromg and it just looks like it on my phone

worn iris
#

I mostly get it the part that upsets me is that np is supposed to have nice vecor capabilities yet i have to do this instead of a crossproduct

thick umbraBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.