Git Product home page Git Product logo

Comments (4)

MirkoDziadzka avatar MirkoDziadzka commented on April 27, 2024

Just curious, is there a way in grumpy to implement a builtin function in Python?

My naïve approach of adding a Python implementation of sorted() to lib/__buildin__.py does not work (see https://github.com/MirkoDziadzka/grumpy/commit/0fe34aea09691d26a3ad6c31b4ab323638de270c)

from grumpy.

trotterdylan avatar trotterdylan commented on April 27, 2024

This limitation is briefly discussed here: #50

I haven't given it a whole lot of thought but I think it's actually a bit of a pain to make this work. The basic issue is that the __builtin__ Go package would need to import grumpy (the runtime package) to work properly, and the runtime package would need to import __builtin__ so that it could populate it with the stuff implemented in Go. So there's a circular dependency.

Unfortunately, we do need to get this working because there is Python code out there that adds its own functions to __builtin__.

One possible approach would be to have __builtin__.py replace its own module __dict__ with __go__.grumpy.Builtins. I don't think this would work as-is, but something along these lines:

# __builtin__.py
from __go__.grumpy import Builtins
import sys
sys.modules['__builtin__'].__dict__ = Builtins

from grumpy.

MirkoDziadzka avatar MirkoDziadzka commented on April 27, 2024

looks like sorted() is already implemented in #100 via 384954e

from grumpy.

trotterdylan avatar trotterdylan commented on April 27, 2024

Whoops, sorry about that Mirko. Closing this.

from grumpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.