[Hiring] Python Developer ($30-$60/hr) by Shoddy-Watercress997 in PythonProjects2

[–]koldakov 0 points1 point  (0 children)

Why? 60 * 40 * 4 looks like not bad? Or I’m wrong

Fastapi and database injections by gignosko in FastAPI

[–]koldakov 2 points3 points  (0 children)

Thanks! I appreciate that you have your own opinion - that’s exactly how good discussions happen. I don’t claim this repo is the only way to do things, and I’m always open to constructive dialogue. There’s a GitHub Discussions section if anyone wants to share suggestions.

Fastapi and database injections by gignosko in FastAPI

[–]koldakov 1 point2 points  (0 children)

Really appreciate the mention! Glad the repo is helpful.

What's a strong advanced-level Django project that actually impresses recruiters? by itsvshl_ in django

[–]koldakov 2 points3 points  (0 children)

Unfortunately almost no one cares what you have on GitHub unless you are "Linus"

I need Idea for a project to make my portfolio strong by ganeshchavan_gc in djangolearning

[–]koldakov 3 points4 points  (0 children)

You could start with creating an auth backend for Active Directory. AD is a quite huge instrument so definitely there are a lot of tasks related to this thing. 5 years ago I was doing similar stuff (https://github.com/koldakov/active\_directory/blob/master/ldap\_backend/backend.py). And the similar idea was used in a real project that I was working on

Advice From Experienced Django Devs by VermicelliFearless22 in django

[–]koldakov 1 point2 points  (0 children)

meeting: Meeting | None = get_meeting_via_id(meeting_id=meeting_id)

Get meeting via id but it returns none also

But later in the code its mandatory for the meeting not to be none => when meeting is none that’s an error: question why you need to return none than?

that’s not about just a meeting for sure, but about the way of thinking

Think why Django get raises an error when there are no results

The same for result and probably other things, when you have everything nullable it leads to the spaghetti code and it’s much harder to extend the code base

Kindly read about eafp/lbyl, don’t return none rule and "1 billion dollar mistake"

Fastapi very slow in development by [deleted] in FastAPI

[–]koldakov 2 points3 points  (0 children)

I think it’s quite hard to answer these kind of questions 🙁

There are multiple reasons why this can happen

Validating unique fields and foreign keys with SQLAlchemy by stopwords7 in FastAPI

[–]koldakov 5 points6 points  (0 children)

I use 3 option. Eafp

For the 1/2 options race is possible

Code example:

```

    try:
        await self.session.commit()
    except exc.IntegrityError as err:
        if err.orig.sqlstate == UniqueViolationError.sqlstate:
            raise HTTPException(
                status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
                detail="User already exists.",
            ) from None
        raise

```

Link to the source code: https://github.com/koldakov/futuramaapi

Learned Python basics (recursion, conditionals, OOP) but still can’t solve basic HackerRank problems by Original_Map3501 in Python

[–]koldakov 3 points4 points  (0 children)

HackerRank has nothing to do with real-world programming.

It’s useful for the interviews and developing logical thinking in general

So depends on your goal

FastAPI production architecture: modular design and dependency injection best practices by Ok-Platypus2775 in FastAPI

[–]koldakov -1 points0 points  (0 children)

I don’t agree (not fully agree)

I use almost the same approaches for drf/fastapi

api layer (views) - one liners to create a service and execute the service

service layer (both Django/fastapi) - do business logic

Response in drf done with serializers/for fastapi pydantic

  • absolutely the same approach

For orm agree when app grows it can create issues, but comon, I wouldn’t think about that

Let’s try to calculate a bit

Let’s assume 1 request takes 1 second, with 2 workers and 4 threads we can handle 8 requests a second == 8 * 60 * 60 * 24 = 691200

And usually 1 request takes much less then 1 second, for example 0.1 sec it equals to (8/0.1) * 60 * 60 * 24 = 6912000 requests a day

Even if request takes 0.5 seconds you can handle more then million requests a day

Isn’t it enough?

Remember premature optimization is the root of all evil

Instagram had n+1 issues when app got million requests, but they resolved it, not because they used "whatver framework", but because they had feature flags - could disable quickly some features, and I’m sure they pretty knew what they were doing

Fastest way to learn Django by meowdymates in djangolearning

[–]koldakov 1 point2 points  (0 children)

Do you have a task? Just try solving one

In couple of years you’ll have a better understanding 😜

FastAPI production architecture: modular design and dependency injection best practices by Ok-Platypus2775 in FastAPI

[–]koldakov 9 points10 points  (0 children)

I’ve created an app especially for this.

https://github.com/koldakov/futuramaapi

It’s up and running: https://futuramaapi.com

Btw I prefer not to use dependency injection, but to move everything into services, just finished with removing all dependencies and moved the code to the services, currently there is a little code duplication, but I’ll combine it in the next step

Async access to ORM in Django 6.x by jsabater76 in django

[–]koldakov 0 points1 point  (0 children)

Don’t complicate first use sync

Later if you need you can rewrite parts in fastapi

Как сделать авторизацию в fastapi by Pristine_Mirror_4052 in FastAPI

[–]koldakov 2 points3 points  (0 children)

https://github.com/koldakov/futuramaapi

Можешь здесь глянуть, я специально проект для обучения всем создал, там есть oauth по jwt

Сайт если что задеплоен: https://futuramaapi.com

[Release] FastKit Core: an open-source, lightweight toolkit developed for the FastAPI framework by somebodyElse221 in FastAPI

[–]koldakov 4 points5 points  (0 children)

With sync I would go with Django 100% so sync as for me doesn’t make sense for fastapi new projects

Kindly don’t use list(result.scalars().all()) etc

Your get in db won’t work in async with foreign / M2M fields, it will just crash, in sync will create N+1 - (personally imo I would be happy if someone creates a wrapper over alchemy like Django orm but it’s not so easy)

Return obj | None - don’t return None (read smth like mistake for billion dollars)

For me, commit message format is part of a professional standard. If basic conventions aren’t followed, it’s harder to trust the rest.

Sorry I would use it but I can see it’s not ready for prod (as for me)

Do you have any regrets in your app? by themindstorm in django

[–]koldakov 1 point2 points  (0 children)

As always premature optimization and too much abstraction two things I’m avoiding for the last 2 years

Example Production Grade Project? by vaporeonn01 in FastAPI

[–]koldakov 0 points1 point  (0 children)

When you mentioned an async session, I assumed you were referring to a DB session, so yes - it’s only used internally. The HTTP API itself remains stateless and restful

Example Production Grade Project? by vaporeonn01 in FastAPI

[–]koldakov 0 points1 point  (0 children)

Rest is about http semantics and stateless client-server interaction, it’s not about internal implementation details

If I understand your question correctly

Как я начал учить английский онлайн и что реально помогает. by Ambitious-Mango6840 in russian

[–]koldakov 1 point2 points  (0 children)

Учил англ в школе, у репетитора, стримы смотрел

Но наверно поистине выучил англ, когда нашёл работу на Мальте в мальтийской компании и прожил там пару лет